模块 java.base

类 CheckedInputStream

所有已实现的接口:
Closeable , AutoCloseable

public class CheckedInputStream extends FilterInputStream
一个输入流,它还维护正在读取的数据的校验和。然后可以使用校验和来验证输入数据的完整性。
自从:
1.1
参见:
  • 构造方法详细信息

    • CheckedInputStream

      public CheckedInputStream(InputStream  in, Checksum  cksum)
      使用指定的校验和创建输入流。
      参数:
      in - 输入流
      cksum - 校验和
  • 方法详情

    • read

      public int read() throws IOException
      读取一个字节。如果没有输入可用,将阻塞。
      重写:
      read 在类 FilterInputStream
      返回:
      读取的字节,如果到达流的末尾则为 -1。
      抛出:
      IOException - 如果发生 I/O 错误
      参见:
    • read

      public int read(byte[] buf, int off, int len) throws IOException
      读入字节数组。如果 len 不为零,则该方法会阻塞,直到某些输入可用;否则,不读取任何字节并返回 0
      重写:
      read 在类 FilterInputStream
      参数:
      buf - 读取数据的缓冲区
      off - 目标数组中的起始偏移量 b
      len - 读取的最大字节数
      返回:
      实际读取的字节数,如果到达流的末尾则为 -1。
      抛出:
      NullPointerException - 如果 bufnull
      IndexOutOfBoundsException - 如果 off 为负,len 为负,或者 len 大于 buf.length - off
      IOException - 如果发生 I/O 错误
      参见:
    • skip

      public long skip(long n) throws IOException
      跳过指定数量的输入字节。
      重写:
      skip 在类 FilterInputStream
      参数:
      n - 要跳过的字节数
      返回:
      实际跳过的字节数
      抛出:
      IOException - 如果发生 I/O 错误
      参见:
    • getChecksum

      public Checksum  getChecksum()
      返回此输入流的校验和。
      返回:
      校验和值