Added in API level 1

ParcelFileDescriptor.AutoCloseInputStream

public static class ParcelFileDescriptor.AutoCloseInputStream
extends FileInputStream

java.lang.Object
   ↳ java.io.InputStream
     ↳ java.io.FileInputStream
       ↳ android.os.ParcelFileDescriptor.AutoCloseInputStream


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

Summary

Public constructors

AutoCloseInputStream(ParcelFileDescriptor pfd)

Public methods

void close()

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

int read()

Reads a byte of data from this input stream.

int read(byte[] b, int off, int len)

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

int read(byte[] b)

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

Inherited methods

Public constructors

AutoCloseInputStream

Added in API level 1
public AutoCloseInputStream (ParcelFileDescriptor pfd)

Parameters
pfd ParcelFileDescriptor

Public methods

close

Added in API level 1
public void close ()

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.

Throws
IOException

read

Added in API level 1
public int read ()

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

Returns
int the next byte of data, or -1 if the end of the file is reached.

Throws
IOException

read

Added in API level 1
public int read (byte[] b, 
                int off, 
                int len)

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 byte: 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.

Returns
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.

Throws
IOException

read

Added in API level 1
public int read (byte[] b)

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 byte: the buffer into which the data is read.

Returns
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.

Throws
IOException