? PeekableInputStream

????????:
Closeable, AutoCloseable

Implements a buffered input stream, which allows to peek into the buffers first bytes. This comes in handy when manually implementing scanners, lexers, parsers, and the like.
  • ???????

    • PeekableInputStream

      public PeekableInputStream(InputStream inputStream, int bufferSize)
      Creates a new instance, which filters the given input stream, and uses the given buffer size.
      ??:
      inputStream - The input stream, which is being buffered.
      bufferSize - The size of the CircularByteBuffer, which is used internally.
    • PeekableInputStream

      public PeekableInputStream(InputStream inputStream)
      Creates a new instance, which filters the given input stream, and uses a reasonable default buffer size (8192).
      ??:
      inputStream - The input stream, which is being buffered.
  • ??????

    • peek

      public boolean peek(byte[] sourceBuffer) throws IOException
      Returns whether the next bytes in the buffer are as given by sourceBuffer. This is equivalent to peek(byte[], int, int) with offset == 0, and length == sourceBuffer.length
      ??:
      sourceBuffer - the buffer to compare against
      ??:
      true if the next bytes are as given
      ??:
      IOException - Refilling the buffer failed.
    • peek

      public boolean peek(byte[] sourceBuffer, int offset, int length) throws IOException
      Returns whether the next bytes in the buffer are as given by sourceBuffer, {code offset}, and length.
      ??:
      sourceBuffer - the buffer to compare against
      offset - the start offset
      length - the length to compare
      ??:
      true if the next bytes in the buffer are as given
      ??:
      IOException - if there is a problem calling fillBuffer()