public class BoundedInputStream extends InputStream
This is useful to wrap ServletInputStreams. The ServletInputStream will block if you try to read content from it that isn't there, because it doesn't know whether the content hasn't arrived yet or whether the content has finished. So, one of these, initialized with the Content-length sent in the ServletInputStream's header, will stop it blocking, providing it's been sent with a correct content length.
| Constructor and Description |
|---|
BoundedInputStream(InputStream in) |
BoundedInputStream(InputStream in,
long size)
Creates a new
BoundedInputStream that wraps the given input
stream and limits it to a certain size. |
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
void |
close() |
boolean |
isPropagateClose() |
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
void |
reset() |
void |
setPropagateClose(boolean propagateClose) |
long |
skip(long n) |
String |
toString() |
public BoundedInputStream(InputStream in, long size)
BoundedInputStream that wraps the given input
stream and limits it to a certain size.in - The wrapped input streamsize - The maximum number of bytes to returnpublic BoundedInputStream(InputStream in)
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 int available()
throws IOException
available in class InputStreamIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOExceptionpublic void reset()
throws IOException
reset in class InputStreamIOExceptionpublic void mark(int readlimit)
mark in class InputStreampublic boolean markSupported()
markSupported in class InputStreampublic boolean isPropagateClose()
public void setPropagateClose(boolean propagateClose)
Copyright © 2004–2022 The Apache Software Foundation. All rights reserved.