Package org.apache.commons.compress.utils

# Class ChecksumVerifyingInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
java.util.zip.CheckedInputStream
org.apache.commons.compress.utils.ChecksumVerifyingInputStream

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

Direct Known Subclasses:
  `CRC32VerifyingInputStream`

public class ChecksumVerifyingInputStream extends CheckedInputStream
Verifies the checksum of the data read once the stream is exhausted.

Since:
  1.7
This class is not thread-safe

- ## Field Summary

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

  `in`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ChecksumVerifyingInputStream(Checksum checksum, InputStream in, long size, long expectedChecksum)`
  Constructs a new instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `long`
  `getBytesRemaining()`
  Gets the byte count remaining to read.
  `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.

  ### Methods inherited from class java.util.zip.CheckedInputStream

  `getChecksum, skip`

  ### 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

  - ### ChecksumVerifyingInputStream

    public ChecksumVerifyingInputStream(Checksum checksum, InputStream in, long size, long expectedChecksum)
    Constructs a new instance.
    Parameters:
      `checksum` - Checksum implementation.
      `in` - the stream to wrap
      `size` - the of the stream's content
      `expectedChecksum` - the expected checksum

- ## Method Details

  - ### getBytesRemaining

    public long getBytesRemaining()
    Gets the byte count remaining to read.
    Returns:
      bytes remaining to read.
    Since:
      1.21

  - ### read

    public int read() throws IOException
    Reads a single byte from the stream
    Overrides:
      `read` in class `CheckedInputStream`
    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 `CheckedInputStream`
    Throws:
      `IOException` - if the underlying stream throws or the stream is exhausted and the Checksum doesn't match the expected value