Build 1.0_r1(from source)

Interface ReadableByteChannel

All Superinterfaces:
Channel, Closeable
All Known Subinterfaces:
ByteChannel, ScatteringByteChannel
All Known Implementing Classes:
DatagramChannel, FileChannel, Pipe.SourceChannel, SocketChannel

public interface ReadableByteChannel
extends Channel

A ReadableByteChannel is a type of Channel that can read bytes.

Reads are synchronous on a ReadableByteChannel, that is, if a read is already in progress on the channel then subsequent reads will block until the first read completes. It is undefined whether non-read operations will block.

Method Summary
 int read(ByteBuffer buffer)
          Reads bytes from the channel into the given buffer.
Methods inherited from interface java.nio.channels.Channel
close, isOpen

Method Detail


int read(ByteBuffer buffer)
         throws IOException
Reads bytes from the channel into the given buffer.

The maximum number of bytes that will be read is the remaining() number of bytes in the buffer when the method invoked. The bytes will be read into the buffer starting at the buffer's position.

The call may block if other threads are also attempting to read on the same channel.

Upon completion, the buffer's position() is updated to the end of the bytes that were read. The buffer's limit() is unmodified.

buffer - the byte buffer to receive the bytes.
the number of bytes actually read.
NonReadableChannelException - if the channel was not opened for reading.
ClosedChannelException - if the channel was already closed.
AsynchronousCloseException - if another thread closes the channel during the read.
ClosedByInterruptException - if another thread interrupt the calling thread during the read.
IOException - another IO exception occurs, details are in the message.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature