Build 1.0_r1(from source)

Interface WritableByteChannel

All Superinterfaces:
Channel, Closeable
All Known Subinterfaces:
ByteChannel, GatheringByteChannel
All Known Implementing Classes:
DatagramChannel, FileChannel, Pipe.SinkChannel, SocketChannel

public interface WritableByteChannel
extends Channel

A WritableByteChannel is a type of Channel that can write bytes.

Writes are synchronous on a WritableByteChannel, that is, if a write is already in progress on the channel then subsequent writes will block until the first write completes. It is undefined whether non-write operations will block.

Method Summary
 int write(ByteBuffer buffer)
          Writes bytes from the given buffer to the channel.
Methods inherited from interface java.nio.channels.Channel
close, isOpen

Method Detail


int write(ByteBuffer buffer)
          throws IOException
Writes bytes from the given buffer to the channel.

The maximum number of bytes that will be written is the remaining() number of bytes in the buffer when the method invoked. The bytes will be written from the buffer starting at the buffer's position.

The call may block if other threads are also attempting to write on the same channel.

Upon completion, the buffer's position() is updated to the end of the bytes that were written. The buffer's limit() is unmodified.

buffer - the byte buffer containing the bytes to be written.
the number of bytes actually written.
NonWritableChannelException - if the channel was not opened for writing.
ClosedChannelException - if the channel was already closed.
AsynchronousCloseException - if another thread closes the channel during the write.
ClosedByInterruptException - if another thread interrupt the calling thread during the write.
IOException - another IO exception occurs, details are in the message.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature