import java.io.*; class tester { public static void main(String args[]) { FileInputStream inputFile1,inputTest; // declare a file input object DataInputStream in1, in2; int lineNumber = 1; boolean testFail = false; if (args.length == 2) { try { // Get the name of the file to be compared inputFile1 = new FileInputStream(args[0]); // Get the name of the benchmark (i.e. the file that you should generate as a test case) inputTest = new FileInputStream(args[1]); // Convert our input stream to a // DataInputStream in1 = new DataInputStream(inputFile1); in2 = new DataInputStream(inputTest); while (in2.available()!=0) { //compare the the lines read from the first file to the ones read from the second file if(!(in1.readLine()).equals(in2.readLine())) { System.out.println("Error occured at line number: " + lineNumber); testFail = true; } lineNumber++; } in1.close(); in2.close(); if (testFail) System.out.println ("Test has failed: output file disagrees with input file"); else System.out.println ("Test Successful.."); } catch (Exception e) { System.err.println ("Error Reading/Writing from/to file"); } } else { System.out.println ("Wrong Number of arguments"); } } }