question: public static String collapseNewlines ( String argStr ) { char last = argStr . charAt ( 0 ) ; StringBuffer argBuf = new StringBuffer ( ) ; for ( int cIdx = 0 ; cIdx < argStr . length ( ) ; cIdx ++ ) { char ch = argStr . charAt ( cIdx ) ; if ( ch != '\n' || last != '\n' ) { argBuf . append ( ch ) ; last = ch ; } } return argBuf . toString ( ) ; }
target:  Remove/collapse multiple newline characters.