InputStream.ReadAllBytes Method

Definition

Reads all remaining bytes from the input stream.

[Android.Runtime.Register("readAllBytes", "()[B", "GetReadAllBytesHandler", ApiSince=33)]
public virtual byte[]? ReadAllBytes ();
[<Android.Runtime.Register("readAllBytes", "()[B", "GetReadAllBytesHandler", ApiSince=33)>]
abstract member ReadAllBytes : unit -> byte[]
override this.ReadAllBytes : unit -> byte[]

Returns

Byte[]

a byte array containing the bytes read from this input stream

Attributes

Remarks

Reads all remaining bytes from the input stream. This method blocks until all remaining bytes have been read and end of stream is detected, or an exception is thrown. This method does not close the input stream.

When this stream reaches end of stream, further invocations of this method will return an empty byte array.

Note that this method is intended for simple cases where it is convenient to read all bytes into a byte array. It is not intended for reading input streams with large amounts of data.

The behavior for the case where the input stream is asynchronously closed, or the thread interrupted during the read, is highly input stream specific, and therefore not specified.

If an I/O error occurs reading from the input stream, then it may do so after some, but not all, bytes have been read. Consequently the input stream may not be at end of stream and may be in an inconsistent state. It is strongly recommended that the stream be promptly closed if an I/O error occurs.

Added in 9.

Java documentation for java.io.InputStream.readAllBytes().

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