public class ChannelOutputStream extends BufferOutputStream implements BinaryOutput
Note that it is not safe to use several ChannelOutputStreams
over the
same channel (even if synchronized). For file channels, the FileChannelOutputStream
can be used if you need this functionality. Use copy-pipes if you need it
on other channel types.
If multiple threads use the same instance of this class, the access to the instance must be synchronized.
ChannelInputStream
MINIMAL_BUFFER_SIZE
Constructor and Description |
---|
ChannelOutputStream(int bufferSize,
boolean bufferDirect,
java.nio.channels.WritableByteChannel writeChannel)
Creates a new instance of ChannelOutputStream.
|
Modifier and Type | Method and Description |
---|---|
protected void |
write(java.nio.ByteBuffer buffer)
Writes the buffered data to the write channel.
|
bufferedSize, close, flush, isDirty, prepareOutput, setBufferedSizeLimit, write, write, write, write, write
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
flush, prepareOutput
public ChannelOutputStream(int bufferSize, boolean bufferDirect, java.nio.channels.WritableByteChannel writeChannel) throws java.io.IOException
bufferSize
- the size of the internal buffer used for flushingbufferDirect
- allocate the internal buffer as direct
writeChannel
- the channel into which to write datajava.io.IOException
- if there was an error using writeChannelprotected void write(java.nio.ByteBuffer buffer) throws java.io.IOException
write
in class BufferOutputStream
buffer
- the buffer from which to write datajava.io.IOException
- if there was an error writing the data