Question: Program: Java FILE INPUT-OUTPUT Concept Summary: 1. File Handling 2. Exception handling Description Write a program that reads two files and compares the contents of

Program: Java

FILE INPUT-OUTPUT

Concept Summary:

1. File Handling

2. Exception handling

Description Write a program that reads two files and compares the contents of the file.

Design the program that reads two files and compares their contents.

The program calls a method that reads the file one line at a time. If the lines are the same the program skips the line. If the lines are different then the program prints the line number followed by the different lines from each file. The program checks to see if the files have the same number of lines. If the files do not have an equal number of lines, it should throw an error such as \"NOT ENOUGH DATA\". The program should also throw an error if the program cannot find the file or open it.

SAMPLE OUTPUT:

Line 1

> Humpty Dumpty tat on a wall Line 3

> All the kings horss and all the kings men

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 Programming Questions!