FileChannel.Read Method

Definition

Overloads

Read(ByteBuffer, Int64)

Reads a sequence of bytes from this channel into the given buffer, starting at the given file position.

Read(ByteBuffer)

Reads a sequence of bytes from this channel into the given buffer.

Read(ByteBuffer[])

Reads a sequence of bytes from this channel into the given buffers.

Read(ByteBuffer[], Int32, Int32)

Reads a sequence of bytes from this channel into a subsequence of the given buffers.

Read(ByteBuffer, Int64)

Reads a sequence of bytes from this channel into the given buffer, starting at the given file position.

[Android.Runtime.Register("read", "(Ljava/nio/ByteBuffer;J)I", "GetRead_Ljava_nio_ByteBuffer_JHandler")]
public abstract int Read (Java.Nio.ByteBuffer? dst, long position);
[<Android.Runtime.Register("read", "(Ljava/nio/ByteBuffer;J)I", "GetRead_Ljava_nio_ByteBuffer_JHandler")>]
abstract member Read : Java.Nio.ByteBuffer * int64 -> int

Parameters

dst
ByteBuffer

The buffer into which bytes are to be transferred

position
Int64

The file position at which the transfer is to begin; must be non-negative

Returns

The number of bytes read, possibly zero, or -1 if the given position is greater than or equal to the file's current size

Attributes

Exceptions

if this channel is closed by another thread while this method is executing.

if another thread interrupts the calling thread while this operation is in progress. The calling thread will have the interrupt state set, and the channel will be closed.

if this channel is closed.

if position is less than 0.

if another I/O error occurs.

if the channel has not been opened in a mode that permits reading.

Remarks

Reads a sequence of bytes from this channel into the given buffer, starting at the given file position.

This method works in the same manner as the #read(ByteBuffer) method, except that bytes are read starting at the given file position rather than at the channel's current position. This method does not modify this channel's position. If the given position is greater than the file's current size then no bytes are read.

Java documentation for java.nio.channels.FileChannel.read(java.nio.ByteBuffer, long).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Read(ByteBuffer)

Reads a sequence of bytes from this channel into the given buffer.

[Android.Runtime.Register("read", "(Ljava/nio/ByteBuffer;)I", "GetRead_Ljava_nio_ByteBuffer_Handler")]
public abstract int Read (Java.Nio.ByteBuffer? dst);
[<Android.Runtime.Register("read", "(Ljava/nio/ByteBuffer;)I", "GetRead_Ljava_nio_ByteBuffer_Handler")>]
abstract member Read : Java.Nio.ByteBuffer -> int

Parameters

Returns

Implements

Attributes

Exceptions

if another thread closes the channel during the read.

if another thread interrupts the calling thread during the read.

if this channel is closed.

if another I/O error occurs, details are in the message.

if the channel has not been opened in a mode that permits reading.

Remarks

Reads a sequence of bytes from this channel into the given buffer.

Bytes are read starting at this channel's current file position, and then the file position is updated with the number of bytes actually read. Otherwise this method behaves exactly as specified in the ReadableByteChannel interface.

Java documentation for java.nio.channels.FileChannel.read(java.nio.ByteBuffer).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Read(ByteBuffer[])

Reads a sequence of bytes from this channel into the given buffers.

[Android.Runtime.Register("read", "([Ljava/nio/ByteBuffer;)J", "")]
public long Read (Java.Nio.ByteBuffer[]? dsts);
[<Android.Runtime.Register("read", "([Ljava/nio/ByteBuffer;)J", "")>]
abstract member Read : Java.Nio.ByteBuffer[] -> int64
override this.Read : Java.Nio.ByteBuffer[] -> int64

Parameters

dsts
ByteBuffer[]

Returns

Implements

Attributes

Exceptions

if this channel is closed by another thread during this read operation.

if the thread is interrupted by another thread during this read operation.

if this channel is closed.

if another I/O error occurs; details are in the message.

if the channel has not been opened in a mode that permits reading.

Remarks

Reads a sequence of bytes from this channel into the given buffers.

Bytes are read starting at this channel's current file position, and then the file position is updated with the number of bytes actually read. Otherwise this method behaves exactly as specified in the ScatteringByteChannel interface.

Java documentation for java.nio.channels.FileChannel.read(java.nio.ByteBuffer[]).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Read(ByteBuffer[], Int32, Int32)

Reads a sequence of bytes from this channel into a subsequence of the given buffers.

[Android.Runtime.Register("read", "([Ljava/nio/ByteBuffer;II)J", "GetRead_arrayLjava_nio_ByteBuffer_IIHandler")]
public abstract long Read (Java.Nio.ByteBuffer[]? dsts, int offset, int length);
[<Android.Runtime.Register("read", "([Ljava/nio/ByteBuffer;II)J", "GetRead_arrayLjava_nio_ByteBuffer_IIHandler")>]
abstract member Read : Java.Nio.ByteBuffer[] * int * int -> int64

Parameters

dsts
ByteBuffer[]
offset
Int32
length
Int32

Returns

Implements

Attributes

Exceptions

if this channel is closed by another thread during this read operation.

if the thread is interrupted by another thread during this read operation.

if this channel is closed.

if start or number , or if start + number is greater than the size of buffers.

if another I/O error occurs; details are in the message.

if the channel has not been opened in a mode that permits reading.

Remarks

Reads a sequence of bytes from this channel into a subsequence of the given buffers.

Bytes are read starting at this channel's current file position, and then the file position is updated with the number of bytes actually read. Otherwise this method behaves exactly as specified in the ScatteringByteChannel interface.

Java documentation for java.nio.channels.FileChannel.read(java.nio.ByteBuffer[], int, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to