com.Ostermiller.util Java Utilities


com.Ostermiller.util
Class CircularByteBuffer.CircularByteBufferOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by com.Ostermiller.util.CircularByteBuffer.CircularByteBufferOutputStream
All Implemented Interfaces:
Closeable, Flushable
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 Summary
protected CircularByteBuffer.CircularByteBufferOutputStream()
           
 
Method Summary
 void close()
          Close the stream, flushing it first.
 void flush()
          Flush the stream.
 void write(byte[] cbuf)
          Write an array of bytes.
 void write(byte[] cbuf, int off, int len)
          Write a portion of an array of bytes.
 void write(int c)
          Write a single byte.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CircularByteBuffer.CircularByteBufferOutputStream

protected CircularByteBuffer.CircularByteBufferOutputStream()
Method Detail

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 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
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
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
Throws:
BufferOverflowException - if buffer does not allow blocking writes and the buffer is full.
IOException - if the stream is closed, or the write is interrupted.
Since:
ostermillerutils 1.00.00

com.Ostermiller.util Java Utilities


Copyright (c) 2001-2007 by Stephen Ostermiller