/** * <p> Writes a byte of data in the buffer. If the buffer already encountered an end of line sequence, and exception will be thrown. * * @param data The byte of data. * @return true if the buffer encountered one of the end of line sequences, false otherwise. */ public boolean write(final byte data){ if (isEndOfLine()){ throw new IllegalStateException("Buffer is in an end of line state. You need to recycle it before writing."); } flushIfNeeded(); circularBuffer.write(data); boolean isEndOfLine = updateEndOfLineMatchingStatus(data); if (isEndOfLine){ flushIfNeeded(); } return isEndOfLine; }
/** * <p> Writes a byte of data in the buffer. If the buffer already encountered an end of line sequence, and exception will be thrown. * * @param data The byte of data. * @return true if the buffer encountered one of the end of line sequences, false otherwise. */ public boolean write(final byte data){ if (isEndOfLine()){ throw new IllegalStateException("Buffer is in an end of line state. You need to recycle it before writing."); } flushIfNeeded(); circularBuffer.write(data); boolean isEndOfLine = updateEndOfLineMatchingStatus(data); if (isEndOfLine){ flushIfNeeded(); } return isEndOfLine; }