@Override public void processDataStream(final InputStream inputStream, final OutputPort<IMonitoringRecord> outputPort) throws IOException { final byte[] buffer = new byte[this.charBuffer.length() * 2]; // NOPMD boolean endOfFile = false; int offset = 0; this.lineNumber = 0; while (!endOfFile) { final int numOfReadBytes = inputStream.read(buffer, offset, buffer.length - offset); if (numOfReadBytes == -1) { /** end of line. */ endOfFile = true; } else { final int numOfBufferedBytes = numOfReadBytes + offset; final int mark = this.processBuffer(buffer, offset, numOfBufferedBytes, outputPort); /** move remaining left. */ for (int j = mark + 1; j < numOfBufferedBytes; j++) { buffer[j - mark - 1] = buffer[j]; } offset = numOfBufferedBytes - mark; } } if (this.charBuffer.position() > 0) { this.createRecord(outputPort); } }