Class CircularByteBuffer.CircularByteBufferOutputStream

java.lang.Object
java.io.OutputStream
org.serviceconnector.util.CircularByteBuffer.CircularByteBufferOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
Enclosing class:
CircularByteBuffer

protected class CircularByteBuffer.CircularByteBufferOutputStream extends OutputStream
Class for writing to a circular byte buffer. If the buffer is full, the writes will either block until there is some space available or throw an IOException based on the CircularByteBuffer's preference.
Since:
ostermillerutils 1.00.00
  • Constructor Details

    • CircularByteBufferOutputStream

      protected CircularByteBufferOutputStream()
  • Method Details

    • close

      public void close() throws IOException
      Close the stream, flushing it first. This will cause the InputStream associated with this circular buffer to read its last bytes once it empties the buffer. Once a stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. 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 OutputStream
      Throws:
      IOException - never.
      Since:
      ostermillerutils 1.00.00
    • flush

      public void flush() throws IOException
      Flush the stream.
      Specified by:
      flush in interface Flushable
      Overrides:
      flush in class OutputStream
      Throws:
      IOException - if the stream is closed.
      Since:
      ostermillerutils 1.00.00
    • write

      public void write(byte[] cbuf) throws IOException, BufferOverflowException
      Write an array of bytes. If the buffer allows blocking writes, this method will block until all the data has been written rather than throw an IOException.
      Overrides:
      write in class OutputStream
      Parameters:
      cbuf - Array of bytes to be written
      Throws:
      BufferOverflowException - if buffer does not allow blocking writes and the buffer is full. If the exception is thrown, no data will have been written since the buffer was set to be non-blocking.
      IOException - if the stream is closed, or the write is interrupted.
      Since:
      ostermillerutils 1.00.00
    • write

      public void write(byte[] cbuf, int off, int len) throws IOException, BufferOverflowException
      Write a portion of an array of bytes. If the buffer allows blocking writes, this method will block until all the data has been written rather than throw an IOException.
      Overrides:
      write in class OutputStream
      Parameters:
      cbuf - Array of bytes
      off - Offset from which to start writing bytes
      len - - Number of bytes to write
      Throws:
      BufferOverflowException - if buffer does not allow blocking writes and the buffer is full. If the exception is thrown, no data will have been written since the buffer was set to be non-blocking.
      IOException - if the stream is closed, or the write is interrupted.
      Since:
      ostermillerutils 1.00.00
    • write

      public void write(int c) throws IOException
      Write a single byte. The byte to be written is contained in the 8 low-order bits of the given integer value; the 24 high-order bits are ignored. If the buffer allows blocking writes, this method will block until all the data has been written rather than throw an IOException.
      Specified by:
      write in class OutputStream
      Parameters:
      c - number of bytes to be written and the buffer is full.
      Throws:
      IOException - if the stream is closed, or the write is interrupted.
      Since:
      ostermillerutils 1.00.00