Build 1.0_r1(from source)

java.nio.channels
Interface GatheringByteChannel

All Superinterfaces:
Channel, Closeable, WritableByteChannel
All Known Implementing Classes:
DatagramChannel, FileChannel, Pipe.SinkChannel, SocketChannel

public interface GatheringByteChannel
extends WritableByteChannel

The interface to channels that can write a set of buffers in a single operation.

The corresponding interface for reads is called ScatteringByteChannel.


Method Summary
 long write(ByteBuffer[] buffers)
          Writes bytes from all the given buffers to the channel.
 long write(ByteBuffer[] buffers, int offset, int length)
          Writes a subset of the given bytes from the buffers to the channel.
 
Methods inherited from interface java.nio.channels.WritableByteChannel
write
 
Methods inherited from interface java.nio.channels.Channel
close, isOpen
 

Method Detail

write

long write(ByteBuffer[] buffers)
           throws IOException
Writes bytes from all the given buffers to the channel.

This method is equivalent to:

 write(buffers, 0, buffers.length);
 

Parameters:
buffers - the buffers containing bytes to be written.
Returns:
the number of bytes actually written.
Throws:
ClosedChannelException - if the channel is closed.
NonWritableChannelException - if the channel is open, but not in a mode that permits writing.
ClosedByInterruptException - if the thread is interrupted in its IO operation by another thread closing the channel.
AsynchronousCloseException - if the write is interrupted by another thread sending an explicit interrupt.
IOException - if some other type of exception occurs. Details are in the message.

write

long write(ByteBuffer[] buffers,
           int offset,
           int length)
           throws IOException
Writes a subset of the given bytes from the buffers to the channel.

This method attempts to write all of the remaining() bytes from length byte buffers, in order, starting at buffers[offset]. The number of bytes actually written is returned.

If a write operation is in progress, subsequent threads will block until the write is completed, and will then contend for the ability to write.

Parameters:
buffers - the array of byte buffers containing the source of remaining bytes that will be attempted to be written.
offset - the index of the first buffer to write.
length - the number of buffers to write.
Returns:
the number of bytes actually written.
Throws:
IndexOutOfBoundsException - if offset < 0="" or=""> buffers.length; or length < 0="" or=""> buffers.length - offset.
NonWritableChannelException - if the channel was not opened for writing.
ClosedChannelException - the channel is currently closed.
AsynchronousCloseException - the channel was closed by another thread while the write was underway.
ClosedByInterruptException - the thread was interrupted by another thread while the write was underway.
IOException - if some other type of exception occurs. Details are in the message.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature