Added in API level 1

AutoCloseInputStream


open class AutoCloseInputStream : FileInputStream
kotlin.Any
   ↳ java.io.InputStream
   ↳ java.io.FileInputStream
   ↳ android.os.ParcelFileDescriptor.AutoCloseInputStream

An InputStream you can create on a ParcelFileDescriptor, which will take care of calling android.os.ParcelFileDescriptor#close for you when the stream is closed.

Summary

Public constructors

Public methods
open Unit

Closes this file input stream and releases any system resources associated with the stream.

open Int

Reads a byte of data from this input stream.

open Int

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

open Int
read(b: ByteArray!, off: Int, len: Int)

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

Inherited functions

Public constructors

AutoCloseInputStream

Added in API level 1
AutoCloseInputStream(pfd: ParcelFileDescriptor!)

Public methods

close

Added in API level 1
open fun close(): Unit

Closes this file input stream and releases any system resources associated with the stream.

If this stream has an associated channel then the channel is closed as well.

Exceptions
java.lang.Exception if this resource cannot be closed
java.io.IOException if an I/O error occurs.

read

Added in API level 1
open fun read(): Int

Reads a byte of data from this input stream. This method blocks if no input is yet available.

Return
Int the next byte of data, or -1 if the end of the file is reached.
Exceptions
java.io.IOException if an I/O error occurs.

read

Added in API level 1
open fun read(b: ByteArray!): Int

Reads up to b.length bytes of data from this input stream into an array of bytes. This method blocks until some input is available.

Parameters
b ByteArray!: the buffer into which the data is read.
Return
Int 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.
Exceptions
java.io.IOException if an I/O error occurs.
java.lang.NullPointerException if b is null.

read

Added in API level 1
open fun read(
    b: ByteArray!,
    off: Int,
    len: Int
): Int

Reads up to len bytes of data from this input stream into an array of bytes. If len is not zero, the method blocks until some input is available; otherwise, no bytes are read and 0 is returned.

Parameters
b ByteArray!: the buffer into which the data is read.
off Int: the start offset in the destination array b
len Int: the maximum number of bytes read.
Return
Int 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.
Exceptions
java.io.IOException if an I/O error occurs.
java.lang.IndexOutOfBoundsException If off is negative, len is negative, or len is greater than b.length - off
java.lang.NullPointerException If b is null.