Class FastLineReader

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class FastLineReader
    extends Object
    implements Closeable
    Line-oriented InputStream reader that uses one buffer for disk buffering and line-termination-finding, in order to improve performance. Implementation detail: All public methods must leave the input buffer in a non-empty state, unless at EOF.
    • Constructor Detail

      • FastLineReader

        public FastLineReader​(InputStream in)
    • Method Detail

      • eof

        public boolean eof()
        Returns:
        true if input is exhausted
      • atEoln

        public boolean atEoln()
        Returns:
        peeks at the next byte in the stream and returns true if it is CR or LF. Returns false if EOF or next byte is not CR or LF.
      • skipNewlines

        public boolean skipNewlines()
        Advance over any EOLN chars (CR or LF)
        Returns:
        true if saw one or more CR or LFs
      • getByte

        public byte getByte()
        Returns:
        Next byte from the input. Do not call if at EOF.
      • peekByte

        public byte peekByte()
        Returns:
        Next byte from the input, without advancing over that byte. Do not call if at EOF.
      • readToEndOfOutputBufferOrEoln

        public int readToEndOfOutputBufferOrEoln​(byte[] outputBuffer,
                                                 int startOutputIndex)
        Read from input until input is exhausted, EOLN is seen, or output buffer is filled
        Parameters:
        outputBuffer - where to put bytes read
        startOutputIndex - where to start putting bytes read
        Returns:
        number of bytes read