public void write ( final int cc ) throws IOException { final byte c = ( byte ) cc ; if ( ( c == ' ' ) || ( c == ' ' ) ) { // new line is started in case of // - CR (regardless of previous character) // - LF if previous character was not CR and not LF if ( c == ' ' || ( c == ' ' && ( lastReceivedByte != ' ' && lastReceivedByte != ' ' ) ) ) { processBuffer ( ) ; } } else { buffer . write ( cc ) ; } lastReceivedByte = c ; }
Write the data to the buffer and flush the buffer if a line separator is detected .