Most visited

Recently visited

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
Known Direct Subclasses


您可以在ParcelFileDescriptor上创建一个InputStream,它将负责在流关闭时为您调用 ParcelFileDescriptor.close()

Summary

Public constructors

ParcelFileDescriptor.AutoCloseInputStream(ParcelFileDescriptor pfd)

Public methods

void close()

关闭此文件输入流并释放与该流关联的所有系统资源。

int read()

从此输入流中读取一个字节的数据。

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

从此输入流读取多达 len个字节的数据字节数组。

int read(byte[] b)

从这个输入流中读取 b.length个字节的数据到一个字节数组中。

Inherited methods

From class java.io.FileInputStream
From class java.io.InputStream
From class java.lang.Object
From interface java.io.Closeable
From interface java.lang.AutoCloseable

Public constructors

ParcelFileDescriptor.AutoCloseInputStream

Added in API level 1
ParcelFileDescriptor.AutoCloseInputStream (ParcelFileDescriptor pfd)

Parameters
pfd ParcelFileDescriptor

Public methods

close

Added in API level 1
void close ()

关闭此文件输入流并释放与该流关联的所有系统资源。

如果此流具有关联的频道,那么该频道也会关闭。

Throws
IOException

read

Added in API level 1
int read ()

从此输入流中读取一个字节的数据。 如果没有输入可用,此方法会阻止。

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
int read (byte[] b, 
                int off, 
                int len)

从这个输入流读取多达len字节的数据到一个字节数组中。 如果len不为零,则该方法阻塞,直到某些输入可用; 否则,不读取字节并返回0

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
int read (byte[] b)

从这个输入流中读取最多b.length个字节的数据到一个字节数组中。 此方法阻塞,直到有些输入可用。

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

Hooray!