A scattering read operation reads, in a single invocation, a
sequence of bytes into one or more of a given sequence of buffers.
Scattering reads are often useful when implementing network protocols or
file formats that, for example, group data into segments consisting of one
or more fixed-length headers followed by a variable-length body. Similar
gathering write operations are defined in the GatheringByteChannel
interface.
Modifier and Type | Method and Description |
---|---|
public long | Returns: The number of bytes read, possibly zero, or-1 if the channel has reached end-of-streamThe buffers into which bytes are to be transferred dsts, int The offset within the buffer array of the first buffer into
which bytes are to be transferred; must be non-negative and no
larger than offset, int dsts.length The maximum number of buffers to be accessed; must be
non-negative and no larger than
length)dsts.length - offset Reads a sequence of bytes from this channel into a subsequence of the given buffers. |
public long | Returns: The number of bytes read, possibly zero, or-1 if the channel has reached end-of-streamThe buffers into which bytes are to be transferred dsts)Reads a sequence of bytes from this channel into the given buffers. |
read | back to summary |
---|---|
public long read(ByteBuffer[] dsts, int offset, int length) throws IOException Reads a sequence of bytes from this channel into a subsequence of the given buffers. An invocation of this method attempts to read up to r bytes from this channel, where r is the total number of bytes remaining in the specified subsequence of the given buffer array, that is, dsts[offset].remaining() + dsts[offset+1].remaining() + ... + dsts[offset+length-1].remaining() Suppose that a byte sequence of length n is read, where
This method may be invoked at any time. If another thread has already initiated a read operation upon this channel, however, then an invocation of this method will block until the first operation is complete.
|
read | back to summary |
---|---|
public long read(ByteBuffer[] dsts) throws IOException Reads a sequence of bytes from this channel into the given buffers. An invocation of this method of the form c.read(dsts, 0, dsts.length);
|