protected boolean wouldProduceSameFile ( String generated , File existing ) throws IOException { Iterator < String > generatedLines = Splitter . on ( EOL ) . split ( generated ) . iterator ( ) ; for ( String prev : Files . readLines ( existing , UTF_8 ) ) { if ( ! generatedLines . hasNext ( ) ) { return false ; } String cur = generatedLines . next ( ) ; if ( ! prev . equals ( cur ) && ! ( prev . startsWith ( "// $Id" ) && cur . startsWith ( "// $Id" ) ) ) { return false ; } } // If the generated output ends with a newline, it'll have one more next from the splitter // that reading the file doesn't produce. if ( generatedLines . hasNext ( ) ) { return generatedLines . next ( ) . equals ( "" ) && ! generatedLines . hasNext ( ) ; } return true ; }
Returns true if the given string has the same content as the file sans svn prop lines .