Class LengthCheckInputStream

  • All Implemented Interfaces:
    com.amazonaws.internal.MetricAware, com.amazonaws.internal.Releasable, Closeable, AutoCloseable

    public class LengthCheckInputStream
    extends com.amazonaws.internal.SdkFilterInputStream
    Used to perform length check to ensure the number of bytes read from the underlying input stream is the same as the expected total.
    • Constructor Detail

      • LengthCheckInputStream

        public LengthCheckInputStream​(InputStream in,
                                      long expectedLength,
                                      boolean includeSkipped)
        Constructs an input stream that performs length check to ensure the number of bytes read from the underlying input stream is the same as the expected total.
        Parameters:
        in - the underlying input stream
        expectedLength - the total length of the data in bytes expected to be read from the underlying input stream; must be non-negative.
        includeSkipped - true if bytes skipped are to be considered as part of the data length; false otherwise. Typically, this parameter should be set to false for uploading data to AWS, but set to true for receiving data from AWS.
    • Method Detail

      • read

        public int read()
                 throws IOException
        Overrides:
        read in class com.amazonaws.internal.SdkFilterInputStream
        Throws:
        AmazonClientException - if the data length read has exceeded the expected total, or if the total data length is not the same as the expected total.
        IOException
      • read

        public int read​(byte[] b,
                        int off,
                        int len)
                 throws IOException
        Overrides:
        read in class com.amazonaws.internal.SdkFilterInputStream
        Throws:
        AmazonClientException - if the data length read has exceeded the expected total, or if the total data length is not the same as the expected total.
        IOException
      • mark

        public void mark​(int readlimit)
        Overrides:
        mark in class com.amazonaws.internal.SdkFilterInputStream
      • reset

        public void reset()
                   throws IOException
        Overrides:
        reset in class com.amazonaws.internal.SdkFilterInputStream
        Throws:
        IOException