public static List < IFileContentResultBean > findEqualFilesWithSameContent ( final File dirToSearch ) { final List < IFileContentResultBean > equalFiles = new ArrayList < IFileContentResultBean > ( ) ; final List < File > allFiles = FileSearchExtensions . findFilesRecursive ( dirToSearch , "*" ) ; for ( int i = 0 ; i < allFiles . size ( ) ; i ++ ) { final File toCompare = allFiles . get ( i ) ; for ( int j = 0 ; j < allFiles . size ( ) ; j ++ ) { final File file = allFiles . get ( j ) ; if ( toCompare . equals ( file ) ) { continue ; } final IFileContentResultBean contentResultBean = CompareFileExtensions . compareFiles ( toCompare , file ) ; final boolean equal = CompareFileExtensions . validateEquality ( contentResultBean ) ; // if equal is true and the list does not contain the same // compareResultBean then add it. if ( equal && ! equalFiles . contains ( contentResultBean ) ) { equalFiles . add ( contentResultBean ) ; } } } return equalFiles ; }
Compare files with the same content .