public final String readNextLine() throws IOException {
  String str=null;
  if (buf_end - buf_pos <= 0) {
    if (fillBuffer() < 0) {
      return null;
    }
  }
  int lineend=-1;
  for (int i=buf_pos; i < buf_end; i++) {
    if (buffer[i] == '\n') {
      lineend=i;
      break;
    }
  }
  if (lineend < 0) {
    final ByteArrayOutputStream input=new ByteArrayOutputStream(512);
    input.write(buffer,buf_pos,buf_end - buf_pos);
    buf_pos=buf_end;
    int c;
    while ((c=read()) != -1 && c != '\n') {
      input.write((char)c);
    }
    if (c == -1 && input.size() == 0) {
      return null;
    }
    final byte[] bytesInput=input.toByteArray();
    if (c == '\n' && bytesInput.length > 0 && bytesInput[bytesInput.length - 1] == '\r') {
      return new String(bytesInput,0,bytesInput.length - 1,charset);
    }
 else {
      return new String(bytesInput,charset);
    }
  }
  if (lineend > 0 && buffer[lineend - 1] == '\r') {
    str=new String(buffer,buf_pos,lineend - buf_pos - 1,charset);
  }
 else {
    str=new String(buffer,buf_pos,lineend - buf_pos,charset);
  }
  buf_pos=lineend + 1;
  return str;
}

public final String readNextLine ( ) throws IOException { String str = null ; if ( buf_end - buf_pos <= 0 ) { if ( fillBuffer ( ) < 0 ) { return null ; } } int lineend = - 1 ; for ( int i = buf_pos ; i < buf_end ; i ++ ) { if ( buffer [ i ] == '\n' ) { lineend = i ; break ; } } if ( lineend < 0 ) { final ByteArrayOutputStream input = new ByteArrayOutputStream ( 512 ) ; input . write ( buffer , buf_pos , buf_end - buf_pos ) ; buf_pos = buf_end ; int c ; while ( ( c = read ( ) ) != - 1 && c != '\n' ) { input . write ( ( char ) c ) ; } if ( c == - 1 && input . size ( ) == 0 ) { return null ; } final byte [ ] bytesInput = input . toByteArray ( ) ; if ( c == '\n' && bytesInput . length > 0 && bytesInput [ bytesInput . length - 1 ] == '\r' ) { return new String ( bytesInput , 0 , bytesInput . length - 1 , charset ) ; } else { return new String ( bytesInput , charset ) ; } } if ( lineend > 0 && buffer [ lineend - 1 ] == '\r' ) { str = new String ( buffer , buf_pos , lineend - buf_pos - 1 , charset ) ; } else { str = new String ( buffer , buf_pos , lineend - buf_pos , charset ) ; } buf_pos = lineend + 1 ; return str ; }
return a next line in string
