Build 1.0_r1(from source)

java.nio.channels
Interface ScatteringByteChannel

All Superinterfaces:
Channel, Closeable, ReadableByteChannel
All Known Implementing Classes:
DatagramChannel, FileChannel, Pipe.SourceChannel, SocketChannel

public interface ScatteringByteChannel
extends ReadableByteChannel

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

The corresponding interface for writes is called GatheringByteChannel.


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

Method Detail

read

long read(ByteBuffer[] buffers)
          throws IOException
Reads bytes from the channel into all the given buffers.

This method is equivalent to:

 read(buffers, 0, buffers.length);
 

Parameters:
buffers - the array of byte buffers to receive the bytes being read.
Returns:
the number of bytes actually read.
Throws:
ClosedChannelException - if the channel is closed.
NonReadableChannelException - if the channel is open, but not in a mode that permits reading.
ClosedByInterruptException - if the thread is interrupted in its IO operation by another thread closing the channel.
AsynchronousCloseException - if the read is interrupted by another thread sending an explicit interrupt.
IOException - if some other type of exception occurs. Details are in the message.

read

long read(ByteBuffer[] buffers,
          int offset,
          int length)
          throws IOException
Reads bytes from the channel into a subset of the given buffers.

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

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

Parameters:
buffers - the array of byte buffers into which the bytes will be read.
offset - the index of the first buffer to read.
length - the maximum number of buffers to read.
Returns:
the number of bytes actually read.
Throws:
IndexOutOfBoundsException - if offset < 0="" or=""> buffers.length; or length < 0="" or=""> buffers.length - offset.
NonReadableChannelException - if the channel was not opened for reading.
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