Top Description Fields Constructors Methods
org.apache.commons.compress.utils

public Class ChecksumVerifyingInputStream

extends CheckedInputStream
Class Inheritance
Known Direct Subclasses
org.apache.commons.compress.utils.CRC32VerifyingInputStream
Imports
java.io.IOException, .InputStream, java.util.zip.CheckedInputStream, .Checksum

Verifies the checksum of the data read once the stream is exhausted.
Since
1.7

Field Summary

Modifier and TypeField and Description
private final long
private long

Constructor Summary

AccessConstructor and Description
public
ChecksumVerifyingInputStream(final Checksum
Checksum implementation.
checksum
,
final InputStream
the stream to wrap
in
,
final long
the of the stream's content
size
,
final long
the expected checksum
expectedChecksum
)

Constructs a new instance.

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

bytes remaining to read.
getBytesRemaining
()

Gets the byte count remaining to read.

public int
read()

Overrides java.util.zip.CheckedInputStream.read.

Reads a single byte from the stream
public int
read(final byte[]
the buffer into which the data is read
b
,
final int
the start offset in the destination array b
off
,
final int
the maximum number of bytes read
len
)

Overrides java.util.zip.CheckedInputStream.read.

Reads from the stream into a byte array.
private void
Inherited from java.util.zip.CheckedInputStream:
getChecksumskip

Field Detail

expectedback to summary
private final long expected
remainingback to summary
private long remaining

Constructor Detail

ChecksumVerifyingInputStreamback to summary
public ChecksumVerifyingInputStream(final Checksum checksum, final InputStream in, final long size, final long expectedChecksum)

Constructs a new instance.

Parameters
checksum:Checksum

Checksum implementation.

in:InputStream

the stream to wrap

size:long

the of the stream's content

expectedChecksum:long

the expected checksum

Method Detail

getBytesRemainingback to summary
public long getBytesRemaining()

Gets the byte count remaining to read.

Returns:long

bytes remaining to read.

Since
1.21
readback to summary
public int read() throws IOException

Overrides java.util.zip.CheckedInputStream.read.

Reads a single byte from the stream

Returns:int

Doc from java.util.zip.CheckedInputStream.read.

the byte read, or -1 if the end of the stream is reached.

Annotations
@Override
Exceptions
IOException:
if the underlying stream throws or the stream is exhausted and the Checksum doesn't match the expected value
readback to summary
public int read(final byte[] b, final int off, final int len) throws IOException

Overrides java.util.zip.CheckedInputStream.read.

Reads from the stream into a byte array.

Parameters
b:byte[]

Doc from java.util.zip.CheckedInputStream.read.

the buffer into which the data is read

off:int

Doc from java.util.zip.CheckedInputStream.read.

the start offset in the destination array b

len:int

Doc from java.util.zip.CheckedInputStream.read.

the maximum number of bytes read

Returns:int

Doc from java.util.zip.CheckedInputStream.read.

the actual number of bytes read, or -1 if the end of the stream is reached.

Annotations
@Override
Exceptions
IOException:
if the underlying stream throws or the stream is exhausted and the Checksum doesn't match the expected value
verifyback to summary
private void verify() throws IOException