Skip to content

Most visited

Recently visited

navigation
Added in API level 1

ScatteringByteChannel

public interface ScatteringByteChannel
implements ReadableByteChannel

java.nio.channels.ScatteringByteChannel
Known Indirect Subclasses


The interface for channels that can read data into a set of buffers in a single operation. The corresponding interface for writes is GatheringByteChannel.

Summary

Public methods

abstract long read(ByteBuffer[] buffers, int offset, int length)

Attempts to read all remaining() bytes from length byte buffers, in order, starting at buffers[offset].

abstract long read(ByteBuffer[] buffers)

Reads bytes from this channel into the specified array of buffers.

Inherited methods

From interface java.nio.channels.ReadableByteChannel
From interface java.nio.channels.Channel
From interface java.io.Closeable
From interface java.lang.AutoCloseable

Public methods

read

Added in API level 1
long read (ByteBuffer[] buffers, 
                int offset, 
                int length)

Attempts to read all 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 ByteBuffer: the array of byte buffers into which the bytes will be copied.
offset int: the index of the first buffer to store bytes in.
length int: the maximum number of buffers to store bytes in.
Returns
long the number of bytes actually read.
Throws
AsynchronousCloseException if the channel is closed by another thread during this read operation.
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.
ClosedChannelException if the channel is closed.
IndexOutOfBoundsException if offset < 0 or length < 0, or if offset + length is greater than the size of buffers.
IOException if another I/O error occurs; details are in the message.
NonWritableChannelException if the channel has not been opened in a mode that permits reading.

read

Added in API level 1
long read (ByteBuffer[] buffers)

Reads bytes from this channel into the specified array of buffers.

This method is equivalent to read(buffers, 0, buffers.length);

Parameters
buffers ByteBuffer: the array of byte buffers to store the bytes being read.
Returns
long the number of bytes actually read.
Throws
AsynchronousCloseException if the channel is closed by another thread during this read operation.
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.
ClosedChannelException if the channel is closed.
IOException if another I/O error occurs; details are in the message.
NonWritableChannelException if the channel has not been opened in a mode that permits reading.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.