Added in API level 3

AutoCloseInputStream


open class AutoCloseInputStream : ParcelFileDescriptor.AutoCloseInputStream
kotlin.Any
   ↳ java.io.InputStream
   ↳ java.io.FileInputStream
   ↳ android.os.ParcelFileDescriptor.AutoCloseInputStream
   ↳ android.content.res.AssetFileDescriptor.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. It has a ParcelFileDescriptor.AutoCloseInputStream member to make delegate calls and during definition it will create seekable or non seekable child object AssetFileDescriptor.AutoCloseInputStream depends on the type of file descriptor to provide different solution.

Summary

Public constructors

Public methods
open Int

open Unit

open FileChannel!

open Unit
mark(readlimit: Int)

open Boolean

open Int

open Int
read(buffer: ByteArray!, offset: Int, count: Int)

open Int
read(buffer: ByteArray!)

open Unit

open Long
skip(count: Long)

Public constructors

AutoCloseInputStream

Added in API level 3
AutoCloseInputStream(fd: AssetFileDescriptor!)

Public methods

available

Added in API level 3
open fun available(): Int
Return
Int an estimate of the number of remaining bytes that can be read (or skipped over) from this input stream without blocking.
Exceptions
java.io.IOException if this file input stream has been closed by calling close or an I/O error occurs.

close

Added in API level 3
open fun close(): Unit
Exceptions
java.lang.Exception if this resource cannot be closed
java.io.IOException if an I/O error occurs.

getChannel

Added in API level 3
open fun getChannel(): FileChannel!
Return
FileChannel! the file channel associated with this file input stream

mark

Added in API level 3
open fun mark(readlimit: Int): Unit
Parameters
readlimit Int: the maximum limit of bytes that can be read before the mark position becomes invalid.

markSupported

Added in API level 3
open fun markSupported(): Boolean
Return
Boolean true if this stream instance supports the mark and reset methods; false otherwise.

read

Added in API level 3
open fun read(): Int
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 3
open fun read(
    buffer: ByteArray!,
    offset: Int,
    count: Int
): Int
Parameters
b the buffer into which the data is read.
off the start offset in the destination array b
len 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.NullPointerException If b is null.
java.lang.IndexOutOfBoundsException If off is negative, len is negative, or len is greater than b.length - off

read

Added in API level 3
open fun read(buffer: ByteArray!): Int
Parameters
b 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.

reset

Added in API level 3
open fun reset(): Unit
Exceptions
java.io.IOException if this stream has not been marked or if the mark has been invalidated.

skip

Added in API level 3
open fun skip(count: Long): Long
Parameters
n the number of bytes to be skipped.
Return
Long the actual number of bytes skipped.
Exceptions
java.io.IOException if n is negative, if the stream does not support seek, or if an I/O error occurs.