Class ChecksumVerifyingInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.commons.compress.utils.ChecksumVerifyingInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
CRC32VerifyingInputStream
public class ChecksumVerifyingInputStream extends InputStream
A stream that verifies the checksum of the data read once the stream is exhausted.- Since:
- 1.7
-
-
Constructor Summary
Constructors Constructor Description ChecksumVerifyingInputStream(Checksum checksum, InputStream in, long size, long expectedChecksum)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()longgetBytesRemaining()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, mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, transferTo
-
-
-
-
Constructor Detail
-
ChecksumVerifyingInputStream
public ChecksumVerifyingInputStream(Checksum checksum, InputStream in, long size, long expectedChecksum)
-
-
Method Detail
-
read
public int read() throws IOExceptionReads 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 IOExceptionReads 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 IOExceptionReads 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
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
getBytesRemaining
public long getBytesRemaining()
- Returns:
- bytes remaining to read
- Since:
- 1.21
-
-