public static IFileContentResultBean compareFileContentByLines ( final File sourceFile , final File fileToCompare ) { final IFileContentResultBean fileContentResultBean = new FileContentResultBean ( sourceFile , fileToCompare ) ; completeCompare ( fileContentResultBean ) ; final boolean simpleEquality = validateEquality ( fileContentResultBean ) ; boolean contentEquality = true ; // Compare the content... if ( simpleEquality ) { try ( BufferedReader sourceReader = ( BufferedReader ) StreamExtensions . getReader ( sourceFile ) ; BufferedReader compareReader = ( BufferedReader ) StreamExtensions . getReader ( fileToCompare ) ; ) { String sourceLine ; String compareLine ; while ( ( sourceLine = sourceReader . readLine ( ) ) != null ) { compareLine = compareReader . readLine ( ) ; if ( compareLine == null || ! sourceLine . equals ( compareLine ) ) { contentEquality = false ; break ; } } } catch ( final FileNotFoundException e ) { contentEquality = false ; } catch ( final IOException e ) { contentEquality = false ; } } fileContentResultBean . setContentEquality ( contentEquality ) ; return fileContentResultBean ; }
Compare file content by lines .