Question: IN JAVA You will write a class called FileCompare. This class will contain one function. The static function, charByChar, that will compare two files character

IN JAVA

You will write a class called FileCompare. This class will contain one function. The static function, charByChar, that will compare two files character by character and report the number of characters that are different. This is not a true full- le comparison. You will actually compare a line from one line to the line at the same location in the other file, character by character. Addition or removal of whole lines will not be detected. Requirements Your function should take in two le names as parameters; you can assume both files exist: The function will read a line from each file. If the lines are different lengths it reports just the line number and moves to the next lines. If they are the same length it compares them character by character. If they match it moves on to the next line in each file. If they do not match, it reports the line number and character positions in that line that do not match. Then moves to the next line in each file. If one of the files has less lines than the the other, it reports the line as not matching. The function will tally: { Number of characters in each file. { Number of characters that do not match in lines of the same length. { Number of lines that are not the same length.

This displays a sample of the output. Your output does not have to match exactly, but should display the same information. Given the following files: File: t1.txt Hello World bazzle foobar

File: t2.txt Hello world bazzle fooBar Running with files t1.txt and t2.txt will result in: Character by character: Unmatched characters: 1:7, 3:4, There are 23 characters in t1.txt There are 23 characters in t2.txt There were 2 unmatched characters in the files There were 0 lines of different length. Given the following files: File: t3.txt Hello World foobar File: t4.txt Hello world fooBar bazzle Running with files t3.txt and t4.txt will result in: Character by character: Unmatched characters: 1:7, 2:4, 3, There are 17 characters in t3.txt There are 23 characters in t4.txt There were 2 unmatched characters in the files There were 1 lines of different length Given the following files: File: t5.txt Hello World foobar File: t6.txt Hello world fooBarABC

Running with files t5.txt and t6.txt will result in: Character by character: Unmatched characters: 1:7, 2, There are 17 characters in t5.txt There are 20 characters in t6.txt There were 1 unmatched characters in the files There were 1 lines of different length

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!