Skip to content

Most visited

Recently visited

navigation
Added in API level 1

GatheringByteChannel

public interface GatheringByteChannel
implements WritableByteChannel

java.nio.channels.GatheringByteChannel
Known Indirect Subclasses


The interface for channels that can write a set of buffers in a single operation. The corresponding interface for read operations is ScatteringByteChannel.

Summary

Public methods

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

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

abstract long write(ByteBuffer[] buffers)

Writes bytes from all the given buffers to a channel.

Inherited methods

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

Public methods

write

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

Attempts to write all remaining() bytes from length byte buffers, in order, starting at buffers[offset]. The number of bytes actually written is returned.

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

Parameters
buffers ByteBuffer: the array of byte buffers that is the source for bytes written to the channel.
offset int: the index of the first buffer in buffers to get bytes from.
length int: the number of buffers to get bytes from.
Returns
long the number of bytes actually written.
Throws
AsynchronousCloseException if the channel is closed by another thread during this write 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 was not opened for writing.

write

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

Writes bytes from all the given buffers to a channel.

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

Parameters
buffers ByteBuffer: the buffers containing bytes to be written.
Returns
long the number of bytes actually written.
Throws
AsynchronousCloseException if the channel is closed by another thread during this write 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 writing.
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.