Package org.serviceconnector.util
Class CircularByteBuffer.CircularByteBufferOutputStream
java.lang.Object
java.io.OutputStream
org.serviceconnector.util.CircularByteBuffer.CircularByteBufferOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
- Enclosing class:
- CircularByteBuffer
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 Summary
Constructors -
Method Summary
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
CircularByteBufferOutputStream
protected CircularByteBufferOutputStream()
-
-
Method Details
-
close
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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException- never.- Since:
- ostermillerutils 1.00.00
-
flush
Flush the stream.- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException- if the stream is closed.- Since:
- ostermillerutils 1.00.00
-
write
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:
writein classOutputStream- 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
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:
writein classOutputStream- Parameters:
cbuf- Array of bytesoff- Offset from which to start writing byteslen- - 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
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:
writein classOutputStream- 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
-