Class ChecksumCalculatingInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- software.amazon.awssdk.services.s3.checksums.ChecksumCalculatingInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class ChecksumCalculatingInputStream extends FilterInputStream
-
-
Field Summary
-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description ChecksumCalculatingInputStream(InputStream in, SdkChecksum cksum)Creates an input stream using the specified Checksum.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getChecksumBytes()intread()Reads from the underlying stream.intread(byte[] buf, int off, int len)Reads up to len bytes at a time from the input stream, updates the checksum.voidreset()Resets stream state, including the running checksum.-
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, skip
-
-
-
-
Constructor Detail
-
ChecksumCalculatingInputStream
public ChecksumCalculatingInputStream(InputStream in, SdkChecksum cksum)
Creates an input stream using the specified Checksum.- Parameters:
in- the input stream to readcksum- the Checksum implementation to use for computing the checksum
-
-
Method Detail
-
read
public int read() throws IOExceptionReads from the underlying stream. If the end of the stream is reached, the running checksum will be appended a byte at a time (1 per read call).- Overrides:
readin classFilterInputStream- Returns:
- byte read, if eos has been reached, -1 will be returned.
- Throws:
IOException
-
read
public int read(byte[] buf, int off, int len) throws IOExceptionReads up to len bytes at a time from the input stream, updates the checksum. If the end of the stream has been reached the checksum will be appended to the last 4 bytes.- Overrides:
readin classFilterInputStream- Parameters:
buf- buffer to write intooff- offset in the buffer to write tolen- maximum number of bytes to attempt to read.- Returns:
- number of bytes written into buf, otherwise -1 will be returned to indicate eos.
- Throws:
IOException
-
reset
public void reset() throws IOExceptionResets stream state, including the running checksum.- Overrides:
resetin classFilterInputStream- Throws:
IOException
-
getChecksumBytes
public byte[] getChecksumBytes()
-
-