Class S3ChecksumValidatingInputStream
- java.lang.Object
-
- java.io.InputStream
-
- software.amazon.awssdk.services.s3.internal.checksums.S3ChecksumValidatingInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Abortable
public class S3ChecksumValidatingInputStream extends InputStream implements Abortable
-
-
Constructor Summary
Constructors Constructor Description S3ChecksumValidatingInputStream(InputStream in, SdkChecksum cksum, long streamLength)Creates an input stream using the specified Checksum, input stream, and length.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort()voidclose()intread()Reads one byte at a time from the input stream, updates the checksum.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.InputStream
available, mark, markSupported, read, skip
-
-
-
-
Constructor Detail
-
S3ChecksumValidatingInputStream
public S3ChecksumValidatingInputStream(InputStream in, SdkChecksum cksum, long streamLength)
Creates an input stream using the specified Checksum, input stream, and length.- Parameters:
in- the input streamcksum- the Checksum implementationstreamLength- the total length of the expected stream (including the extra 4 bytes on the end).
-
-
Method Detail
-
read
public int read() throws IOExceptionReads one byte at a time from the input stream, updates the checksum. If the end of the stream has been reached the checksum will be compared to the stream's checksum amd a SdkClientException will be thrown.- Specified by:
readin classInputStream- Returns:
- byte read, if a read happened, otherwise -1 will be returned to indicate eos.
- 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 compared to the stream's checksum amd a SdkClientException will be thrown.- Overrides:
readin classInputStream- 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 classInputStream- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
-