protected String getNextLine ( int newlineCount ) throws IOException { if ( newlineCount == 0 ) { return "" ; } StringBuffer str = new StringBuffer ( ) ; int b ; while ( pis . available ( ) > 0 ) { b = pis . read ( ) ; if ( b == - 1 ) { return "" ; } if ( b == ' ' ) { newlineCount -- ; if ( newlineCount == 0 ) { log . debug ( "Read lines: " + str . toString ( ) ) ; String [ ] lines = str . toString ( ) . split ( "\n" ) ; // FIXME: this leads to queuing lines so we will have time lag! return lines [ lines . length - 1 ] ; } } str . append ( ( char ) b ) ; } return "" ; }
Method retrieves next line from received bytes sequence