Class ChecksumInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- com.oracle.bmc.objectstorage.transfer.internal.ChecksumInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
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.
-
-
Field Summary
-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description ChecksumInputStream(InputStream in, ChecksumAlgorithm algorithm, String expectedChecksum, long contentLength)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 classesRetryingStream
andMultithreadStream
do not support the skip operation.-
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, reset
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
ChecksumInputStream
public ChecksumInputStream(InputStream in, ChecksumAlgorithm algorithm, String expectedChecksum, long contentLength) throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
-
-
Method Detail
-
read
public int read() throws IOException
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
read
public int read(byte[] b) throws IOException
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
skip
public long skip(long n) throws IOException
This method throws an IOException because the underlying stream classesRetryingStream
andMultithreadStream
do not support the skip operation.- Overrides:
skip
in classFilterInputStream
- Throws:
IOException
-
-