3 import java.io.BufferedReader;
5 import java.io.FileNotFoundException;
6 import java.io.FileReader;
7 import java.io.IOException;
10 public class FileComparator
12 private final File basedir;
13 private BufferedReader expectedReader;
14 private BufferedReader foundReader;
16 public FileComparator(File basedir)
18 this.basedir = basedir;
21 public boolean isEqual(final String expectedFile, final String foundFile)
23 FileNotFoundException,
27 String expected, found;
29 file = new File(basedir, expectedFile);
30 expectedReader = new BufferedReader(new FileReader(file));
32 file = new File(basedir, foundFile);
33 foundReader = new BufferedReader(new FileReader(file));
36 while ((expected = expectedReader.readLine()) != null)
38 found = foundReader.readLine();
39 if (!expected.equals(found))
41 System.err.println("Mismatch!");
42 System.err.println("Expected: " + expected);
43 System.err.println("Found: " + found);
48 if ((found = foundReader.readLine()) != null)
50 System.err.println("Found more content than expected!");
51 System.err.println("Starting with: " + found);