org.apache.commons.io.input

## Class ChecksumInputStream

- java.lang.Object
- - java.io.InputStream
  - - java.io.FilterInputStream
    - - org.apache.commons.io.input.ProxyInputStream
      - - org.apache.commons.io.input.CountingInputStream
        - - org.apache.commons.io.input.ChecksumInputStream

- All Implemented Interfaces:
    Closeable, AutoCloseable

      public final class ChecksumInputStream
      extends org.apache.commons.io.input.CountingInputStream

  Automatically verifies a `Checksum` value once the stream is exhausted or the count threshold is reached.

  If the `Checksum` does not meet the expected value when exhausted, then the input stream throws an `IOException`.

  If you do not need the verification or threshold feature, then use a plain `CheckedInputStream`.

  To build an instance, use `ChecksumInputStream.Builder`.

  See Also:
    `ChecksumInputStream.Builder`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ChecksumInputStream.Builder` Builds a new `ChecksumInputStream`.

    - ### Nested classes/interfaces inherited from class org.apache.commons.io.input.ProxyInputStream

      `ProxyInputStream.AbstractBuilder<T,B extends AbstractStreamBuilder<T,B>>`

  - ### Field Summary

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

      `in`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `afterRead(int n)` Adds the number of read bytes to the count.
    `static ChecksumInputStream.Builder` | `builder()` Constructs a new `ChecksumInputStream.Builder`.
    `long` | `getRemaining()` Gets the byte count remaining to read.

    - ### Methods inherited from class org.apache.commons.io.input.CountingInputStream

      `getByteCount, resetByteCount, skip`

    - ### Methods inherited from class org.apache.commons.io.input.ProxyInputStream

      `available, beforeRead, checkOpen, close, handleIOException, isClosed, mark, markSupported, read, read, read, reset, setReference, unwrap`

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

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

- - ### Method Detail

    - #### afterRead

          protected void afterRead(int n)
                            throws IOException

      Description copied from class: `CountingInputStream`
      Adds the number of read bytes to the count.
      Overrides:
        `afterRead` in class `org.apache.commons.io.input.CountingInputStream`
      Parameters:
        `n` - number of bytes read, or -1 if no more bytes are available
      Throws:
        `IOException` - Not thrown here but subclasses may throw.

    - #### builder

          public static ChecksumInputStream.Builder builder()

      Constructs a new `ChecksumInputStream.Builder`.
      Returns:
        a new `ChecksumInputStream.Builder`.

    - #### getRemaining

          public long getRemaining()

      Gets the byte count remaining to read.
      Returns:
        bytes remaining to read, a negative number means the threshold is unbound.