Package com.amazonaws.util
Class LengthCheckInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
com.amazonaws.internal.SdkFilterInputStream
com.amazonaws.util.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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final boolean
static final boolean
Fields inherited from class java.io.FilterInputStream
in
-
Constructor Summary
ConstructorsConstructorDescriptionLengthCheckInputStream
(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. -
Method Summary
Methods inherited from class com.amazonaws.internal.SdkFilterInputStream
abort, abortIfNeeded, available, close, isMetricActivated, markSupported, release
Methods inherited from class java.io.FilterInputStream
read
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
INCLUDE_SKIPPED_BYTES
public static final boolean INCLUDE_SKIPPED_BYTES- See Also:
-
EXCLUDE_SKIPPED_BYTES
public static final boolean EXCLUDE_SKIPPED_BYTES- See Also:
-
-
Constructor Details
-
LengthCheckInputStream
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 streamexpectedLength
- 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 Details
-
read
- Overrides:
read
in classcom.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
- Overrides:
read
in classcom.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 classcom.amazonaws.internal.SdkFilterInputStream
-
reset
- Overrides:
reset
in classcom.amazonaws.internal.SdkFilterInputStream
- Throws:
IOException
-
skip
- Overrides:
skip
in classcom.amazonaws.internal.SdkFilterInputStream
- Throws:
AmazonClientException
- ifincludeSkipped
is true and the data length skipped has exceeded the expected total.IOException
-