Class ChecksumCalculatingInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.commons.compress.utils.ChecksumCalculatingInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class ChecksumCalculatingInputStream extends InputStream
A stream that calculates the checksum of the data read.- Since:
- 1.14
- This class is not thread-safe
-
-
Constructor Summary
Constructors Constructor Description ChecksumCalculatingInputStream(Checksum checksum, InputStream inputStream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetValue()Returns the calculated checksum.intread()Reads a single byte from the streamintread(byte[] b)Reads a byte array from the streamintread(byte[] b, int off, int len)Reads from the stream into a byte array.longskip(long n)-
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, reset
-
-
-
-
Constructor Detail
-
ChecksumCalculatingInputStream
public ChecksumCalculatingInputStream(Checksum checksum, InputStream inputStream)
-
-
Method Detail
-
read
public int read() throws IOException
Reads a single byte from the stream- Specified by:
readin classInputStream- 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) throws IOException
Reads a byte array from the stream- Overrides:
readin classInputStream- 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:
readin classInputStream- 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:
skipin classInputStream- Throws:
IOException
-
getValue
public long getValue()
Returns the calculated checksum.- Returns:
- the calculated checksum.
-
-