Udostępnij za pośrednictwem


RandomAccessFile.Read Method

Definition

Overloads

Read()

Reads a byte of data from this file.

Read(Byte[])

Reads up to b.length bytes of data from this file into an array of bytes.

Read(Byte[], Int32, Int32)

Reads up to len bytes of data from this file into an array of bytes.

Read()

Reads a byte of data from this file.

[Android.Runtime.Register("read", "()I", "GetReadHandler")]
public virtual int Read ();
[<Android.Runtime.Register("read", "()I", "GetReadHandler")>]
abstract member Read : unit -> int
override this.Read : unit -> int

Returns

the next byte of data, or -1 if the end of the file has been reached.

Attributes

Exceptions

if this file is closed or another I/O error occurs.

Remarks

Reads a byte of data from this file. The byte is returned as an integer in the range 0 to 255 (0x00-0x0ff). This method blocks if no input is yet available.

Although RandomAccessFile is not a subclass of InputStream, this method behaves in exactly the same way as the InputStream#read() method of InputStream.

Java documentation for java.io.RandomAccessFile.read().

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(Byte[])

Reads up to b.length bytes of data from this file into an array of bytes.

[Android.Runtime.Register("read", "([B)I", "GetRead_arrayBHandler")]
public virtual int Read (byte[]? b);
[<Android.Runtime.Register("read", "([B)I", "GetRead_arrayBHandler")>]
abstract member Read : byte[] -> int
override this.Read : byte[] -> int

Parameters

b
Byte[]

the buffer into which the data is read.

Returns

the total number of bytes read into the buffer, or -1 if there is no more data because the end of this file has been reached.

Attributes

Exceptions

if this file is closed or another I/O error occurs.

Remarks

Reads up to b.length bytes of data from this file into an array of bytes. This method blocks until at least one byte of input is available.

Although RandomAccessFile is not a subclass of InputStream, this method behaves in exactly the same way as the InputStream#read(byte[]) method of InputStream.

Java documentation for java.io.RandomAccessFile.read(byte[]).

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(Byte[], Int32, Int32)

Reads up to len bytes of data from this file into an array of bytes.

[Android.Runtime.Register("read", "([BII)I", "GetRead_arrayBIIHandler")]
public virtual int Read (byte[]? b, int off, int len);
[<Android.Runtime.Register("read", "([BII)I", "GetRead_arrayBIIHandler")>]
abstract member Read : byte[] * int * int -> int
override this.Read : byte[] * int * int -> int

Parameters

b
Byte[]

the buffer into which the data is read.

off
Int32

the start offset in array b at which the data is written.

len
Int32

the maximum number of bytes read.

Returns

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the file has been reached.

Attributes

Exceptions

if byteOffset buffer.length.

if this file is closed or another I/O error occurs.

Remarks

Reads up to len bytes of data from this file into an array of bytes. This method blocks until at least one byte of input is available.

Although RandomAccessFile is not a subclass of InputStream, this method behaves in exactly the same way as the InputStream#read(byte[], int, int) method of InputStream.

Java documentation for java.io.RandomAccessFile.read(byte[], 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