/** * 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. * * @throws IOException never. * * @since ostermillerutils 1.00.00 */ @Override public void close() throws IOException { synchronized (CircularByteBuffer.this){ if (!outputStreamClosed && !inputStreamClosed){ flush(); } outputStreamClosed = true; } }
/** * 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. * * @param 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. * @throws IOException if the stream is closed, or the write is interrupted. * * @since ostermillerutils 1.00.00 */ @Override public void write(byte[] cbuf) throws IOException { write(cbuf, 0, cbuf.length); }