public class ChecksumInputStream extends FilterInputStream
A ChecksumInputStream that computes and verifies a checksum for the data read from the stream. Supports CRC32C, SHA-256, SHA-384, and MD5 algorithms.
Checksum verification is performed before the last byte is read. If the computed checksum does not match the expected checksum, an IOException is thrown.
in
Constructor and Description |
---|
ChecksumInputStream(InputStream in,
ChecksumAlgorithm algorithm,
String expectedChecksum,
long contentLength) |
Modifier and Type | Method and Description |
---|---|
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
long |
skip(long n)
This method throws an IOException because the underlying stream classes
RetryingStream and MultithreadStream do not support the skip operation. |
available, close, mark, markSupported, reset
public ChecksumInputStream(InputStream in, ChecksumAlgorithm algorithm, String expectedChecksum, long contentLength) throws NoSuchAlgorithmException
NoSuchAlgorithmException
public int read() throws IOException
read
in class FilterInputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in class FilterInputStream
IOException
public int read(byte[] b) throws IOException
read
in class FilterInputStream
IOException
public long skip(long n) throws IOException
This method throws an IOException because the underlying stream classes RetryingStream
and MultithreadStream
do not support the skip operation.
skip
in class FilterInputStream
IOException
Copyright © 2016–2024. All rights reserved.