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 InputStream
IOException
public int read(byte[] b) throws IOException
read
in class InputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
IOException
public long skip(long n) throws IOException
skip
in class InputStream
IOException
public void mark(int readlimit)
mark
in class InputStream
public void reset() throws IOException
reset
in class InputStream
IOException
public int available() throws IOException
available
in class InputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
public boolean markSupported()
markSupported
in class InputStream
protected void processBytesRead(int bytesRead) throws IOException
IOException
Copyright © 2016–2022. All rights reserved.