Package software.amazon.awssdk.utils.io
Class LengthAwareInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- software.amazon.awssdk.utils.io.LengthAwareInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
@SdkProtectedApi public class LengthAwareInputStream extends FilterInputStream
AnInputStreamthat is aware of its length. This class enforces that we sent exactly the number of bytes equal to the input length. If the wrapped stream has more bytes than the expected length, it will be truncated to length. If the stream has less bytes (i.e. reaches EOF) before the expected length is reached, it will throwIOException.
-
-
Field Summary
-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description LengthAwareInputStream(InputStream in, long length)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidmark(int readlimit)intread()intread(byte[] b, int off, int len)longremaining()voidreset()longskip(long requestedBytesToSkip)-
Methods inherited from class java.io.FilterInputStream
close, markSupported, read
-
-
-
-
Constructor Detail
-
LengthAwareInputStream
public LengthAwareInputStream(InputStream in, long length)
-
-
Method Detail
-
read
public final int read() throws IOException- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
public final int read(byte[] b, int off, int len) throws IOException- Overrides:
readin classFilterInputStream- Throws:
IOException
-
skip
public final long skip(long requestedBytesToSkip) throws IOException- Overrides:
skipin classFilterInputStream- Throws:
IOException
-
available
public final int available() throws IOException- Overrides:
availablein classFilterInputStream- Throws:
IOException
-
mark
public final void mark(int readlimit)
- Overrides:
markin classFilterInputStream
-
reset
public final void reset() throws IOException- Overrides:
resetin classFilterInputStream- Throws:
IOException
-
remaining
public final long remaining()
-
-