FileDocCategorySizeDatePackage
ScatteringByteChannel.javaAPI DocAndroid 1.5 API4369Wed May 06 22:41:04 BST 2009java.nio.channels

ScatteringByteChannel

public interface ScatteringByteChannel implements ReadableByteChannel
The interface for channels that can read data into a set of buffers in a single operation. The corresponding interface for writes is {@link GatheringByteChannel}.
since
Android 1.0

Fields Summary
Constructors Summary
Methods Summary
public longread(java.nio.ByteBuffer[] buffers)
Reads bytes from this channel into the specified array of buffers.

This method is equivalent to {@code read(buffers, 0, buffers.length);}

param
buffers the array of byte buffers to store the bytes being read.
return
the number of bytes actually read.
throws
AsynchronousCloseException if the channel is closed by another thread during this read operation.
throws
ClosedByInterruptException if another thread interrupts the calling thread while the operation is in progress. The interrupt state of the calling thread is set and the channel is closed.
throws
ClosedChannelException if the channel is closed.
throws
IOException if another I/O error occurs; details are in the message.
throws
NonWritableChannelException if the channel has not been opened in a mode that permits reading.
since
Android 1.0

public longread(java.nio.ByteBuffer[] buffers, int offset, int length)
Reads bytes from this channel and stores them in a subset of the specified array of buffers. The subset is defined by {@code offset} and {@code length}, indicating the first buffer and the number of buffers to use. This method attempts to read as many bytes as can be stored in the buffer subset from the channel and returns the number of bytes actually read.

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.

param
buffers the array of byte buffers into which the bytes will be copied.
param
offset the index of the first buffer to store bytes in.
param
length the maximum number of buffers to store bytes in.
return
the number of bytes actually read.
throws
AsynchronousCloseException if the channel is closed by another thread during this read operation.
throws
ClosedByInterruptException if another thread interrupts the calling thread while the operation is in progress. The interrupt state of the calling thread is set and the channel is closed.
throws
ClosedChannelException if the channel is closed.
throws
IndexOutOfBoundsException if {@code offset < 0} or {@code length < 0}, or if {@code offset + length} is greater than the size of {@code buffers}.
throws
IOException if another I/O error occurs; details are in the message.
throws
NonWritableChannelException if the channel has not been opened in a mode that permits reading.
since
Android 1.0