question: public static void assertLinewiseEquals ( String message , String expected , String actual ) { try ( Scanner expectedScanner = new Scanner ( expected ) ; Scanner actualScanner = new Scanner ( actual ) ) { String expectedLine = null ; String actualLine = null ; int lineCounter = 1 ; while ( expectedScanner . hasNextLine ( ) ) { expectedLine = expectedScanner . nextLine ( ) ; if ( actualScanner . hasNextLine ( ) ) { actualLine = actualScanner . nextLine ( ) ; } else { fail ( "Line " + lineCounter + ": actual input has less lines then expected result! Expected: " + expectedLine ) ; } assertEquals ( "Line " + lineCounter + ": " + message + "\n\nExpected:\n" + expected + "\nActual:\n" + actual , expectedLine , actualLine ) ; ++ lineCounter ; } } }
target:  Compares a string linewise, i.e. ignores different linebreak characters. Does this by incrementally reading all expected an actual lines and comparing them linewise.