public class CheckedInputStream
extends FilterInputStream
| java.lang.Object | |||
| java.io.InputStream | |||
| java.io.FilterInputStream | |||
| java.util.zip.CheckedInputStream | |||
一个输入流,也保持正在读取的数据的校验和。 校验和可以用来验证输入数据的完整性。
也可以看看:
Inherited fields |
|---|
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) |
|
|---|---|
java.io.FilterInputStream
|
|
java.io.InputStream
|
|
java.lang.Object
|
|
java.io.Closeable
|
|
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 |