question: private String stripOffCR ( String str ) { String [ ] arr = str . split ( "\n" ) ; StringBuilder buf = new StringBuilder ( ) ; for ( String s : arr ) { if ( s . endsWith ( "\r" ) ) { buf . append ( s . substring ( 0 , s . length ( ) - 1 ) ) ; } else { buf . append ( s ) ; } buf . append ( "\n" ) ; } return buf . toString ( ) ; }
target:  Removes '\r' from the end of every line.