private String readLine(final InputStream is) throws IOException {
  _baos.reset();
  int lastChar=-1;
  int thisChar;
  int nread=0;
  while ((thisChar=is.read()) != -1) {
    nread++;
    _baos.write(thisChar);
    if (lastChar == '\r' && thisChar == '\n') {
      nread-=2;
      final String s=new String(_baos.toByteArray(),0,nread,UTF8);
      if (log.isTraceEnabled())       log.trace("[" + s + "]");
      return s;
    }
    lastChar=thisChar;
  }
  if (thisChar == -1 && nread == 0) {
    if (log.isTraceEnabled())     log.trace("EOF");
    return null;
  }
  throw new IOException("End of input stream?");
}

private String readLine ( final InputStream is ) throws IOException { _baos . reset ( ) ; int lastChar = - 1 ; int thisChar ; int nread = 0 ; while ( ( thisChar = is . read ( ) ) != - 1 ) { nread ++ ; _baos . write ( thisChar ) ; if ( lastChar == '\r' && thisChar == '\n' ) { nread -= 2 ; final String s = new String ( _baos . toByteArray ( ) , 0 , nread , UTF8 ) ; if ( log . isTraceEnabled ( ) ) log . trace ( "[" + s + "]" ) ; return s ; } lastChar = thisChar ; } if ( thisChar == - 1 && nread == 0 ) { if ( log . isTraceEnabled ( ) ) log . trace ( "EOF" ) ; return null ; } throw new IOException ( "End of input stream?" ) ; }
reads and returns everything up to the next crlf sequence . the crlf sequence is consumed , but not returned . bytes are converted to characters
