Android
java.nio.channels
public interface

java.nio.channels.ScatteringByteChannel

java.nio.channels.ScatteringByteChannel ReadableByteChannel

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

Summary

Public Methods

          long  read(ByteBuffer[] buffers, int offset, int length)
Reads bytes from the channel into a subset of the given buffers.
          long  read(ByteBuffer[] buffers)
Reads bytes from the channel into all the given buffers.
Methods inherited from interface java.io.Closeable
Methods inherited from interface java.nio.channels.Channel
Methods inherited from interface java.nio.channels.ReadableByteChannel

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.

Throws

IndexOutOfBoundsException if offset < 0 or > buffers.length; or length < 0 or > buffers.length - offset.
NonReadableChannelException if the channel was not opened for reading.
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 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.

Throws

ClosedChannelException if the channel is closed.
NonReadableChannelException if the channel is open, but not in a mode that permits reading.
ClosedByInterruptException if the thread is interrupted in its IO operation by another thread closing the channel.
AsynchronousCloseException if the read 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