Android
java.nio.channels
public interface

java.nio.channels.GatheringByteChannel

java.nio.channels.GatheringByteChannel WritableByteChannel

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

Summary

Public Methods

          long  write(ByteBuffer[] buffers, int offset, int length)
Writes a subset of the given bytes from the buffers to the channel.
          long  write(ByteBuffer[] buffers)
Writes bytes from all the given buffers to the channel.
Methods inherited from interface java.io.Closeable
Methods inherited from interface java.nio.channels.Channel
Methods inherited from interface java.nio.channels.WritableByteChannel

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.

Throws

IndexOutOfBoundsException if offset < 0 or > buffers.length; or length < 0 or > buffers.length - offset.
NonWritableChannelException if the channel was not opened for writing.
ClosedChannelException the channel is currently closed.
AsynchronousCloseException the channel was closed by another thread while the write was underway.
ClosedByInterruptException the thread was interrupted by another thread while the write was underway.
IOException if some other type of exception occurs. Details are in the message.

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.

Throws

ClosedChannelException if the channel is closed.
NonWritableChannelException if the channel is open, but not in a mode that permits writing.
ClosedByInterruptException if the thread is interrupted in its IO operation by another thread closing the channel.
AsynchronousCloseException if the write is interrupted by another thread sending an explicit interrupt.
IOException if some other type of exception occurs. Details are in the message.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56