java.nio.channels
public
interface
java.nio.channels.GatheringByteChannel
The interface to channels that can write a set of buffers in a single
operation.
The corresponding interface for reads is called
ScatteringByteChannel
.
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.SinkChannel |
Writable sink channel for writing into. |
SocketChannel |
A SocketChannel is a selectable channel for part abstraction of stream
connecting socket. |
Summary
Details
Public Methods
public
long
write(ByteBuffer[] buffers, int offset, int length)
Writes a subset of the given bytes from the buffers to the channel.
This method attempts to write all of the 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 will then contend for the ability to write.
Parameters
buffers
| the array of byte buffers containing the source of remaining
bytes that will be attempted to be written. |
offset
| the index of the first buffer to write. |
length
| the number of buffers to write. |
Returns
- the number of bytes actually written.
public
long
write(ByteBuffer[] buffers)
Writes bytes from all the given buffers to the channel.
This method is equivalent to:
write(buffers, 0, buffers.length);
Parameters
buffers
| the buffers containing bytes to be written. |
Returns
- the number of bytes actually written.