private void compareFileContents(File expected,File actual) throws IOException {
  assertEquals(expected.isDirectory(),actual.isDirectory());
  assertEquals(expected.getName(),actual.getName());
  if (expected.isDirectory()) {
    File[] expectedChildren=expected.listFiles();
    Arrays.sort(expectedChildren);
    File[] actualChildren=actual.listFiles();
    Arrays.sort(actualChildren);
    assertThat(actualChildren,arrayWithSize(expectedChildren.length));
    for (int i=0; i < expectedChildren.length; i++) {
      compareFileContents(expectedChildren[i],actualChildren[i]);
    }
  }
 else {
    assertTrue(Files.equal(expected,actual));
  }
}

private void compareFileContents ( File expected , File actual ) throws IOException { assertEquals ( expected . isDirectory ( ) , actual . isDirectory ( ) ) ; assertEquals ( expected . getName ( ) , actual . getName ( ) ) ; if ( expected . isDirectory ( ) ) { File [ ] expectedChildren = expected . listFiles ( ) ; Arrays . sort ( expectedChildren ) ; File [ ] actualChildren = actual . listFiles ( ) ; Arrays . sort ( actualChildren ) ; assertThat ( actualChildren , arrayWithSize ( expectedChildren . length ) ) ; for ( int i = 0 ; i < expectedChildren . length ; i ++ ) { compareFileContents ( expectedChildren [ i ] , actualChildren [ i ] ) ; } } else { assertTrue ( Files . equal ( expected , actual ) ) ; } }
compare the content of two files or directories recursively .
