Class CircularByteBuffer.CircularByteBufferInputStream

java.lang.Object
java.io.InputStream
org.serviceconnector.util.CircularByteBuffer.CircularByteBufferInputStream
All Implemented Interfaces:
Closeable, AutoCloseable
Enclosing class:
CircularByteBuffer

protected class CircularByteBuffer.CircularByteBufferInputStream extends InputStream
Class for reading from a circular byte buffer.
Since:
ostermillerutils 1.00.00
  • Constructor Details

    • CircularByteBufferInputStream

      protected CircularByteBufferInputStream()
  • Method Details

    • available

      public int available() throws IOException
      Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream. The next caller might be the same thread or or another thread.
      Overrides:
      available in class InputStream
      Returns:
      the number of bytes that can be read from this input stream without blocking.
      Throws:
      IOException - if the stream is closed.
      Since:
      ostermillerutils 1.00.00
    • close

      public void close() throws IOException
      Close the stream. Once a stream has been closed, further read(), available(), mark(), or reset() invocations will throw an IOException. Closing a previously-closed stream, however, has no effect.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStream
      Throws:
      IOException - never.
      Since:
      ostermillerutils 1.00.00
    • mark

      public void mark(int readAheadLimit)
      Mark the present position in the stream. Subsequent calls to reset() will attempt to reposition the stream to this point.

      The readAheadLimit must be less than the size of circular buffer, otherwise this method has no effect.

      Overrides:
      mark in class InputStream
      Parameters:
      readAheadLimit - Limit on the number of bytes that may be read while still preserving the mark. After reading this many bytes, attempting to reset the stream will fail.
      Since:
      ostermillerutils 1.00.00
    • markSupported

      public boolean markSupported()
      Tell whether this stream supports the mark() operation.
      Overrides:
      markSupported in class InputStream
      Returns:
      true, mark is supported.
      Since:
      ostermillerutils 1.00.00
    • read

      public int read() throws IOException
      Read a single byte. This method will block until a byte is available, an I/O error occurs, or the end of the stream is reached.
      Specified by:
      read in class InputStream
      Returns:
      The byte read, as an integer in the range 0 to 255 (0x00-0xff), or -1 if the end of the stream has been reached
      Throws:
      IOException - if the stream is closed.
      Since:
      ostermillerutils 1.00.00
    • read

      public int read(byte[] cbuf) throws IOException
      Read bytes into an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.
      Overrides:
      read in class InputStream
      Parameters:
      cbuf - Destination buffer.
      Returns:
      The number of bytes read, or -1 if the end of the stream has been reached
      Throws:
      IOException - if the stream is closed.
      Since:
      ostermillerutils 1.00.00
    • read

      public int read(byte[] cbuf, int off, int len) throws IOException
      Read bytes into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.
      Overrides:
      read in class InputStream
      Parameters:
      cbuf - Destination buffer.
      off - Offset at which to start storing bytes.
      len - Maximum number of bytes to read.
      Returns:
      The number of bytes read, or -1 if the end of the stream has been reached
      Throws:
      IOException - if the stream is closed.
      Since:
      ostermillerutils 1.00.00
    • reset

      public void reset() throws IOException
      Reset the stream. If the stream has been marked, then attempt to reposition i at the mark. If the stream has not been marked, or more bytes than the readAheadLimit have been read, this method has no effect.
      Overrides:
      reset in class InputStream
      Throws:
      IOException - if the stream is closed.
      Since:
      ostermillerutils 1.00.00
    • skip

      public long skip(long n) throws IOException, IllegalArgumentException
      Skip bytes. This method will block until some bytes are available, an I/O error occurs, or the end of the stream is reached.
      Overrides:
      skip in class InputStream
      Parameters:
      n - The number of bytes to skip
      Returns:
      The number of bytes actually skipped
      Throws:
      IllegalArgumentException - if n is negative.
      IOException - if the stream is closed.
      Since:
      ostermillerutils 1.00.00