|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.InputStream
org.apache.commons.io.input.BoundedInputStream
public class BoundedInputStream
This is a stream that will only supply bytes up to a certain length - if its position goes above that, it will stop.
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 Summary | |
|---|---|
BoundedInputStream(InputStream in)
Creates a new BoundedInputStream that wraps the given input
stream and is unlimited. |
|
BoundedInputStream(InputStream in,
long size)
Creates a new BoundedInputStream that wraps the given input
stream and limits it to a certain size. |
|
| Method Summary | |
|---|---|
int |
available()
|
void |
close()
Invokes the delegate's close() method
if isPropagateClose() is true. |
boolean |
isPropagateClose()
Indicates whether the close() method
should propagate to the underling InputStream. |
void |
mark(int readlimit)
Invokes the delegate's mark(int) method. |
boolean |
markSupported()
Invokes the delegate's markSupported() method. |
int |
read()
Invokes the delegate's read() method if
the current position is less than the limit. |
int |
read(byte[] b)
Invokes the delegate's read(byte[]) method. |
int |
read(byte[] b,
int off,
int len)
Invokes the delegate's read(byte[], int, int) method. |
void |
reset()
Invokes the delegate's reset() method. |
void |
setPropagateClose(boolean propagateClose)
Set whether the close() method
should propagate to the underling InputStream. |
long |
skip(long n)
Invokes the delegate's skip(long) method. |
String |
toString()
Invokes the delegate's toString() method. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
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)
BoundedInputStream that wraps the given input
stream and is unlimited.
in - The wrapped input stream| Method Detail |
|---|
public int read()
throws IOException
read() method if
the current position is less than the limit.
read in class InputStreamIOException - if an I/O error occurs
public int read(byte[] b)
throws IOException
read(byte[]) method.
read in class InputStreamb - the buffer to read the bytes into
IOException - if an I/O error occurs
public int read(byte[] b,
int off,
int len)
throws IOException
read(byte[], int, int) method.
read in class InputStreamb - the buffer to read the bytes intooff - The start offsetlen - The number of bytes to read
IOException - if an I/O error occurs
public long skip(long n)
throws IOException
skip(long) method.
skip in class InputStreamn - the number of bytes to skip
IOException - if an I/O error occurs
public int available()
throws IOException
available in class InputStreamIOExceptionpublic String toString()
toString() method.
toString in class ObjecttoString()
public void close()
throws IOException
close() method
if isPropagateClose() is true.
close in interface Closeableclose in class InputStreamIOException - if an I/O error occurs
public void reset()
throws IOException
reset() method.
reset in class InputStreamIOException - if an I/O error occurspublic void mark(int readlimit)
mark(int) method.
mark in class InputStreamreadlimit - read ahead limitpublic boolean markSupported()
markSupported() method.
markSupported in class InputStreampublic boolean isPropagateClose()
close() method
should propagate to the underling InputStream.
true if calling close()
propagates to the close() method of the
underlying stream or false if it does not.public void setPropagateClose(boolean propagateClose)
close() method
should propagate to the underling InputStream.
propagateClose - true if calling
close() propagates to the close()
method of the underlying stream or
false if it does not.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||