public static class ParcelFileDescriptor.AutoCloseInputStream extends FileInputStream
ParcelFileDescriptor.close()
for you when the stream is closed.Constructor and Description |
---|
AutoCloseInputStream(ParcelFileDescriptor pfd) |
Modifier and Type | Method and Description |
---|---|
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)
Reads up to
b.length bytes of data from this input
stream into an array of bytes. |
int |
read(byte[] b,
int off,
int len)
Reads up to
len bytes of data from this input stream
into an array of bytes. |
available, finalize, getChannel, getFD, skip
mark, markSupported, reset
public AutoCloseInputStream(ParcelFileDescriptor pfd)
public void close() throws IOException
FileInputStream
If this stream has an associated channel then the channel is closed as well.
close
in interface Closeable
close
in interface AutoCloseable
close
in class FileInputStream
IOException
- if an I/O error occurs.public int read() throws IOException
FileInputStream
read
in class FileInputStream
-1
if the end of the
file is reached.IOException
- if an I/O error occurs.public int read(byte[] b) throws IOException
FileInputStream
b.length
bytes of data from this input
stream into an array of bytes. This method blocks until some input
is available.read
in class FileInputStream
b
- the buffer into which the data is read.-1
if there is no more data because the end of
the file has been reached.IOException
- if an I/O error occurs.InputStream.read(byte[], int, int)
public int read(byte[] b, int off, int len) throws IOException
FileInputStream
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.read
in class FileInputStream
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.-1
if there is no more data because the end of
the file has been reached.IOException
- if an I/O error occurs.InputStream.read()