Comparing text files w/ Junit
        Posted  
        
            by jon077
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by jon077
        
        
        
        Published on 2009-01-21T20:27:26Z
        Indexed on 
            2010/06/09
            1:22 UTC
        
        
        Read the original article
        Hit count: 345
        
I am comparing text files in junit using:
  public static void assertReaders(BufferedReader expected,
          BufferedReader actual) throws IOException {
    String line;
    while ((line = expected.readLine()) != null) {
      assertEquals(line, actual.readLine());
    }
    assertNull("Actual had more lines then the expected.", actual.readLine());
    assertNull("Expected had more lines then the actual.", expected.readLine());
  }
Is this a good way to compare text files? What is preferred?
© Stack Overflow or respective owner