Class ChecksumVerifyingInputStream
java.lang.Object
java.io.InputStream
org.apache.commons.compress.utils.ChecksumVerifyingInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
CRC32VerifyingInputStream
A stream that verifies the checksum of the data read once the stream is
exhausted.
- Since:
- 1.7
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate long
private final Checksum
private final long
private final InputStream
-
Constructor Summary
ConstructorsConstructorDescriptionChecksumVerifyingInputStream
(Checksum checksum, InputStream in, long size, long expectedChecksum) -
Method Summary
Methods inherited from class java.io.InputStream
available, mark, markSupported, readAllBytes, readNBytes, reset, transferTo
-
Field Details
-
in
-
bytesRemaining
private long bytesRemaining -
expectedChecksum
private final long expectedChecksum -
checksum
-
-
Constructor Details
-
ChecksumVerifyingInputStream
public ChecksumVerifyingInputStream(Checksum checksum, InputStream in, long size, long expectedChecksum)
-
-
Method Details
-
read
Reads a single byte from the stream- Specified by:
read
in classInputStream
- Throws:
IOException
- if the underlying stream throws or the stream is exhausted and the Checksum doesn't match the expected value
-
read
Reads a byte array from the stream- Overrides:
read
in classInputStream
- Throws:
IOException
- if the underlying stream throws or the stream is exhausted and the Checksum doesn't match the expected value
-
read
Reads from the stream into a byte array.- Overrides:
read
in classInputStream
- Throws:
IOException
- if the underlying stream throws or the stream is exhausted and the Checksum doesn't match the expected value
-
skip
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
getBytesRemaining
public long getBytesRemaining()- Returns:
- bytes remaining to read
- Since:
- 1.21
-