public class CheckedInputStream
extends FilterInputStream
java.lang.Object | |||
↳ | java.io.InputStream | ||
↳ | java.io.FilterInputStream | ||
↳ | java.util.zip.CheckedInputStream |
一个输入流,也保持正在读取的数据的校验和。 校验和可以用来验证输入数据的完整性。
也可以看看:
Inherited fields |
---|
From class java.io.FilterInputStream
|
Public constructors |
|
---|---|
CheckedInputStream(InputStream in, Checksum cksum) 使用指定的校验和创建输入流。 |
Public methods |
|
---|---|
Checksum |
getChecksum() 返回此输入流的校验和。 |
int |
read() 读取一个字节。 |
int |
read(byte[] buf, int off, int len) 读入一个字节数组。 |
long |
skip(long n) 跳过指定的输入字节数。 |
Inherited methods |
|
---|---|
From class java.io.FilterInputStream
|
|
From class java.io.InputStream
|
|
From class java.lang.Object
|
|
From interface java.io.Closeable
|
|
From interface java.lang.AutoCloseable
|
CheckedInputStream (InputStream in, Checksum cksum)
使用指定的校验和创建输入流。
Parameters | |
---|---|
in |
InputStream : the input stream |
cksum |
Checksum : the Checksum |
Checksum getChecksum ()
返回此输入流的校验和。
Returns | |
---|---|
Checksum |
the Checksum value |
int read ()
读取一个字节。 如果没有输入可用,将会阻止。
Returns | |
---|---|
int |
the byte read, or -1 if the end of the stream is reached. |
Throws | |
---|---|
IOException |
if an I/O error has occurred |
int read (byte[] buf, int off, int len)
读入一个字节数组。 如果len
不为零,则该方法会阻塞,直到某些输入可用; 否则,不读取字节并返回0
。
Parameters | |
---|---|
buf |
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 actual number of bytes read, or -1 if the end of the stream is reached. |
Throws | |
---|---|
NullPointerException |
If buf is null . |
IndexOutOfBoundsException |
If off is negative, len is negative, or len is greater than buf.length - off |
IOException |
if an I/O error has occurred |
long skip (long n)
跳过指定的输入字节数。
Parameters | |
---|---|
n |
long : the number of bytes to skip |
Returns | |
---|---|
long |
the actual number of bytes skipped |
Throws | |
---|---|
IOException |
if an I/O error has occurred |