public class BackupDataInputStream
extends InputStream
java.lang.Object | ||
↳ | java.io.InputStream | |
↳ | android.app.backup.BackupDataInputStream |
提供InputStream
的界面,用于在还原操作期间访问实体的数据。 在BackupAgentHelper
机制内由BackupHelper
类使用。
当BackupHelper.restoreEntity()
,当前实体的标题已经从底层的BackupDataInput
读取。 该实体的密钥字符串和总数据大小分别可通过该类的getKey()
和size()
方法获得。
注意:调用者应小心不要查找或关闭底层数据源,也不要从流中读取超过 size()
个字节。
也可以看看:
Public methods |
|
---|---|
String |
getKey() 报告备份数据集中与此实体关联的密钥字符串。 |
int |
read() 从流中读取一个字节的实体数据,并将其作为整数值返回。 |
int |
read(byte[] b, int offset, int size) 最多可将 |
int |
read(byte[] b) 将足够的实体数据读入一个字节数组以填充该数组。 |
int |
size() 报告当前实体可用数据的总字节数。 |
Inherited methods |
|
---|---|
From class java.io.InputStream
|
|
From class java.lang.Object
|
|
From interface java.io.Closeable
|
|
From interface java.lang.AutoCloseable
|
String getKey ()
报告备份数据集中与此实体关联的密钥字符串。
Returns | |
---|---|
String |
The key string for this entity, equivalent to calling getKey() on the underlying BackupDataInput . |
int read ()
从流中读取一个字节的实体数据,并将其作为整数值返回。 如果从流中读取超过size()
个字节的数据,则此方法的输出未定义。
Returns | |
---|---|
int |
The byte read, or undefined if the end of the stream has been reached. |
Throws | |
---|---|
IOException |
int read (byte[] b, int offset, int size)
最多可将 size
个字节的数据读入一个字节数组,从数组中的位置 offset
开始。
Parameters | |
---|---|
b |
byte : Byte array into which the data will be read |
offset |
int : The data will be stored in b beginning at this index within the array. |
size |
int : The number of bytes to read in this operation. If insufficient data exists within the entity to fulfill this request, only as much data will be read as is available. |
Returns | |
---|---|
int |
The number of bytes of data read, or zero if all of the entity's data has already been read. |
Throws | |
---|---|
IOException |
int read (byte[] b)
将足够的实体数据读入一个字节数组以填充该数组。
Parameters | |
---|---|
b |
byte : Byte array to fill with data from the stream. If the stream does not have sufficient data to fill the array, then the contents of the remainder of the array will be undefined. |
Returns | |
---|---|
int |
The number of bytes of data read, or zero if all of the entity's data has already been read. |
Throws | |
---|---|
IOException |
int size ()
报告当前实体可用数据的总字节数。
Returns | |
---|---|
int |
The number of data bytes available, equivalent to calling getDataSize() on the underlying BackupDataInput . |