Condividi tramite


InputStream.Available Method

Definition

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected.

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

Returns

an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking or 0 when it reaches the end of the input stream.

Attributes

Exceptions

if this stream is closed or an error occurs

Remarks

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. The read might be on the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.

Note that while some implementations of InputStream will return the total number of bytes in the stream, many will not. It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream.

A subclass's implementation of this method may choose to throw an IOException if this input stream has been closed by invoking the #close() method.

The available method of InputStream always returns 0.

This method should be overridden by subclasses.

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

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