java.nio.channels
public
interface
java.nio.channels.ScatteringByteChannel
The interface to channels that can read a set of buffers in a single
operation.
The corresponding interface for writes is called
GatheringByteChannel
.
Known Indirect Subclasses
DatagramChannel |
A DatagramChannel is a selectable channel for part abstraction of datagram
socket. |
FileChannel |
An abstract channel type for interaction with a platform file. |
Pipe.SourceChannel |
Readable source channel for reading from. |
SocketChannel |
A SocketChannel is a selectable channel for part abstraction of stream
connecting socket. |
Summary
Details
Public Methods
public
long
read(ByteBuffer[] buffers, int offset, int length)
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.
public
long
read(ByteBuffer[] buffers)
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.