Class ChecksumVerifyingInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- java.util.zip.CheckedInputStream
-
- org.apache.commons.compress.utils.ChecksumVerifyingInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
- Direct Known Subclasses:
CRC32VerifyingInputStream
public class ChecksumVerifyingInputStream extends java.util.zip.CheckedInputStreamVerifies the checksum of the data read once the stream is exhausted.- Since:
- 1.7
-
-
Constructor Summary
Constructors Constructor Description ChecksumVerifyingInputStream(java.util.zip.Checksum checksum, java.io.InputStream in, long size, long expectedChecksum)Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetBytesRemaining()Gets the byte count remaining to read.intread()Reads a single byte from the streamintread(byte[] b, int off, int len)Reads from the stream into a byte array.-
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset
-
-
-
-
Constructor Detail
-
ChecksumVerifyingInputStream
public ChecksumVerifyingInputStream(java.util.zip.Checksum checksum, java.io.InputStream in, long size, long expectedChecksum)Constructs a new instance.- Parameters:
checksum- Checksum implementation.in- the stream to wrapsize- the of the stream's contentexpectedChecksum- the expected checksum
-
-
Method Detail
-
getBytesRemaining
public long getBytesRemaining()
Gets the byte count remaining to read.- Returns:
- bytes remaining to read.
- Since:
- 1.21
-
read
public int read() throws java.io.IOExceptionReads a single byte from the stream- Overrides:
readin classjava.util.zip.CheckedInputStream- Throws:
java.io.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 java.io.IOExceptionReads from the stream into a byte array.- Overrides:
readin classjava.util.zip.CheckedInputStream- Throws:
java.io.IOException- if the underlying stream throws or the stream is exhausted and the Checksum doesn't match the expected value
-
-