question: private String readLine ( ) { StringBuffer sb = new StringBuffer ( ) ; while ( buf . remaining ( ) > 0 ) { char c = ( char ) buf . get ( ) ; if ( c == '\r' ) { if ( buf . remaining ( ) > 0 ) { char n = ( char ) buf . get ( buf . position ( ) ) ; if ( n == '\n' ) { buf . get ( ) ; } } break ; } else if ( c == '\n' ) { break ; } sb . append ( c ) ; } return sb . toString ( ) ; }
target:  Read a line of text.  This follows the semantics of readLine() in DataInput -- it reads character by character until a '\n' is encountered.  If a '\r' is encountered, it is discarded.