IScatteringByteChannel.Read Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
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[])
Reads a sequence of bytes from this channel into the given buffers.
[Android.Runtime.Register("read", "([Ljava/nio/ByteBuffer;)J", "GetRead_arrayLjava_nio_ByteBuffer_Handler:Java.Nio.Channels.IScatteringByteChannelInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public long Read (Java.Nio.ByteBuffer[]? dsts);
[<Android.Runtime.Register("read", "([Ljava/nio/ByteBuffer;)J", "GetRead_arrayLjava_nio_ByteBuffer_Handler:Java.Nio.Channels.IScatteringByteChannelInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member Read : Java.Nio.ByteBuffer[] -> int64
Parameters
- dsts
- ByteBuffer[]
The buffers into which bytes are to be transferred
Returns
The number of bytes read, possibly zero,
or -1
if the channel has reached end-of-stream
- Attributes
Exceptions
if the channel is closed by another thread during this read operation.
if another thread interrupts the calling thread while the operation is in progress. The interrupt state of the calling thread is set and the channel is closed.
if the 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.
An invocation of this method of the form c.read(dsts)
behaves in exactly the same manner as the invocation
<blockquote>
c.read(dsts, 0, dsts.length);
</blockquote>
Java documentation for java.nio.channels.ScatteringByteChannel.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:Java.Nio.Channels.IScatteringByteChannelInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public long Read (Java.Nio.ByteBuffer[]? dsts, int offset, int length);
[<Android.Runtime.Register("read", "([Ljava/nio/ByteBuffer;II)J", "GetRead_arrayLjava_nio_ByteBuffer_IIHandler:Java.Nio.Channels.IScatteringByteChannelInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member Read : Java.Nio.ByteBuffer[] * int * int -> int64
Parameters
- dsts
- ByteBuffer[]
The buffers into which bytes are to be transferred
- offset
- Int32
The offset within the buffer array of the first buffer into
which bytes are to be transferred; must be non-negative and no
larger than dsts.length
- length
- Int32
The maximum number of buffers to be accessed; must be
non-negative and no larger than
dsts.length
- offset
Returns
The number of bytes read, possibly zero,
or -1
if the channel has reached end-of-stream
- Attributes
Exceptions
if the channel is closed by another thread during this read operation.
if another thread interrupts the calling thread while the operation is in progress. The interrupt state of the calling thread is set and the channel is closed.
if the channel is closed.
if offset
or length
, or if
offset + length
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.
An invocation of this method attempts to read up to r bytes from this channel, where r is the total number of bytes remaining the specified subsequence of the given buffer array, that is,
<blockquote>
dsts[offset].remaining()
+ dsts[offset+1].remaining()
+ ... + dsts[offset+length-1].remaining()
</blockquote>
at the moment that this method is invoked.
Suppose that a byte sequence of length n is read, where 0
<=
n <=
r. Up to the first dsts[offset].remaining()
bytes of this sequence are transferred into buffer dsts[offset]
, up to the next dsts[offset+1].remaining()
bytes are transferred into buffer dsts[offset+1]
, and so forth, until the entire byte sequence is transferred into the given buffers. As many bytes as possible are transferred into each buffer, hence the final position of each updated buffer, except the last updated buffer, is guaranteed to be equal to that buffer's limit.
This method may be invoked at any time. If another thread has already initiated a read operation upon this channel, however, then an invocation of this method will block until the first operation is complete.
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.