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 Details

    • 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 stream
      cksum - the Checksum implementation
      streamLength - the total length of the expected stream (including the extra 4 bytes on the end).
  • Method Details

    • read

      public int read() throws IOException
      Reads 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:
      read in class InputStream
      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 IOException
      Reads 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:
      read in class InputStream
      Parameters:
      buf - buffer to write into
      off - offset in the buffer to write to
      len - 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 IOException
      Resets stream state, including the running checksum.
      Overrides:
      reset in class InputStream
      Throws:
      IOException
    • abort

      public void abort()
      Description copied from interface: Abortable
      Aborts the execution of the task. Multiple calls to abort or calling abort an already aborted task should return without error.
      Specified by:
      abort in interface Abortable
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStream
      Throws:
      IOException