public class ContentLengthVerifyingInputStream extends InputStream
A wrapper over an InputStream whose length is known, which verifies that
the length of the wrapped stream matches its known length.
NOTE: This implementation of content length verification does not support InputStream.reset()
and the verification is disabled upon invocation of InputStream.reset().
| Modifier and Type | Field and Description |
|---|---|
protected long |
contentLength |
protected InputStream |
delegate |
protected boolean |
isVerificationEnabled |
protected long |
totalBytesProcessed |
| Constructor and Description |
|---|
ContentLengthVerifyingInputStream(InputStream delegate,
long contentLength) |
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
void |
close() |
void |
mark(int readlimit) |
boolean |
markSupported() |
protected void |
processBytesRead(int bytesRead) |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
void |
reset() |
long |
skip(long n) |
protected final InputStream delegate
protected final long contentLength
protected long totalBytesProcessed
protected boolean isVerificationEnabled
@ConstructorProperties(value={"delegate","contentLength"}) public ContentLengthVerifyingInputStream(InputStream delegate, long contentLength)
public int read()
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] b)
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
read in class InputStreamIOExceptionpublic long skip(long n)
throws IOException
skip in class InputStreamIOExceptionpublic void mark(int readlimit)
mark in class InputStreampublic void reset()
throws IOException
reset in class InputStreamIOExceptionpublic int available()
throws IOException
available in class InputStreamIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOExceptionpublic boolean markSupported()
markSupported in class InputStreamprotected void processBytesRead(int bytesRead)
throws IOException
IOExceptionCopyright © 2016–2022. All rights reserved.