Package org.apache.commons.compress.utils

# Class ChecksumCalculatingInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.apache.commons.compress.utils.ChecksumCalculatingInputStream

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

public class ChecksumCalculatingInputStream extends FilterInputStream
Calculates the checksum of the data read.

Since:
  1.14
This class is not thread-safe

- ## Field Summary

  ### Fields inherited from class java.io.FilterInputStream

  `in`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ChecksumCalculatingInputStream(Checksum checksum, InputStream inputStream)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `long`
  `getValue()`
  Returns the calculated checksum.
  `int`
  `read()`
  Reads a single byte from the stream
  `int`
  `read(byte[] b, int off, int len)`
  Reads from the stream into a byte array.
  `long`
  `skip(long n)`

  ### Methods inherited from class java.io.FilterInputStream

  `available, close, mark, markSupported, read, reset`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ChecksumCalculatingInputStream

    public ChecksumCalculatingInputStream(Checksum checksum, InputStream inputStream)

- ## Method Details

  - ### getValue

    public long getValue()
    Returns the calculated checksum.
    Returns:
      the calculated checksum.

  - ### read

    public int read() throws IOException
    Reads a single byte from the stream
    Overrides:
      `read` in class `FilterInputStream`
    Throws:
      `IOException` - if the underlying stream throws or the stream is exhausted and the Checksum doesn't match the expected value

  - ### read

    public int read(byte[] b, int off, int len) throws IOException
    Reads from the stream into a byte array.
    Overrides:
      `read` in class `FilterInputStream`
    Throws:
      `IOException` - if the underlying stream throws or the stream is exhausted and the Checksum doesn't match the expected value

  - ### skip

    public long skip(long n) throws IOException
    Overrides:
      `skip` in class `FilterInputStream`
    Throws:
      `IOException`