fill in the code can you solve it quickly please? import java.io.* ; import java.util.ArrayList; import java.util.Scanner
Question:
fill in the code can you solve it quickly please?
import java.io.* ;
import java.util.ArrayList;
import java.util.Scanner ;
/**
This class contains a method compare() that checks if the corresponding lines (strings) in
two input text files, file1 and file2, are different.
If the two lines are the same it prints the line number followed by ":" followed by the line contents of file1 only
If the lines are different it prints (on a single line) the line number followed by ":" followed by the line of file1 followed by
a "|" followed by the line of file2
If file1 has a line but file2 does not (i.e. the number of lines in file1 is greater than the number in file2 then
it prints the line number followed by ":" followed by the line of file1 followed bya "|"
If file2 has a line but file1 does not (i.e. the number of lines in file2 is greater than the number in file1 then
it prints the line number followed by ":" followed by a "|" followed by the line of file2
You must use loops to compare the files.
NOTE: You may not import anything other than what is already imported.
*/
public class FileCompare
{
private String file1 ;
private String file2 ;
/**
Initializes instance variables
@param file1 the first file name
@param file2 the second file name
*/
public FileCompare(String file1, String file2)
{
this.file1 = file1 ;
this.file2 = file2 ;
}
/**
Write a method: public void compare() according to the instructions above
If either file1 of file2 does not exist, then a FileNotFoundException is
thrown automatically. The method compare() should not catch I/O exceptions
*/
//-----------Start below here. To do: approximate lines of code = 23
// Write the method
//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.
}
Introduction to Business Law
ISBN: 9780324826999
3rd Edition
Authors: Jeff rey F. Beatty, Susan S. Samuelson