? BoundedInputStream
java.lang.Object
java.io.InputStream
org.apache.commons.io.input.BoundedInputStream
- ????????:
Closeable
,AutoCloseable
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.
- ???????:
- 2.0
-
?????
????????Creates a newBoundedInputStream
that wraps the given input stream and is unlimited.BoundedInputStream
(InputStream in, long size) Creates a newBoundedInputStream
that wraps the given input stream and limits it to a certain size. -
????
??????????int
void
close()
boolean
Indicates whether theclose()
method should propagate to the underlingInputStream
.void
mark
(int readlimit) Invokes the delegate'smark(int)
method.boolean
Invokes the delegate'smarkSupported()
method.int
read()
Invokes the delegate'sread()
method if the current position is less than the limit.int
read
(byte[] b) Invokes the delegate'sread(byte[])
method.int
read
(byte[] b, int off, int len) Invokes the delegate'sread(byte[], int, int)
method.void
reset()
Invokes the delegate'sreset()
method.void
setPropagateClose
(boolean propagateClose) Set whether theclose()
method should propagate to the underlingInputStream
.long
skip
(long n) Invokes the delegate'sskip(long)
method.toString()
Invokes the delegate'stoString()
method.??????? java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
???????
-
BoundedInputStream
Creates a newBoundedInputStream
that wraps the given input stream and limits it to a certain size.- ??:
in
- The wrapped input streamsize
- The maximum number of bytes to return
-
BoundedInputStream
Creates a newBoundedInputStream
that wraps the given input stream and is unlimited.- ??:
in
- The wrapped input stream
-
-
??????
-
read
Invokes the delegate'sread()
method if the current position is less than the limit.- ???:
read
???InputStream
- ??:
- the byte read or -1 if the end of stream or the limit has been reached.
- ??:
IOException
- if an I/O error occurs.
-
read
Invokes the delegate'sread(byte[])
method.- ??:
read
???InputStream
- ??:
b
- the buffer to read the bytes into- ??:
- the number of bytes read or -1 if the end of stream or the limit has been reached.
- ??:
IOException
- if an I/O error occurs.
-
read
Invokes the delegate'sread(byte[], int, int)
method.- ??:
read
???InputStream
- ??:
b
- the buffer to read the bytes intooff
- The start offsetlen
- The number of bytes to read- ??:
- the number of bytes read or -1 if the end of stream or the limit has been reached.
- ??:
IOException
- if an I/O error occurs.
-
skip
Invokes the delegate'sskip(long)
method.- ??:
skip
???InputStream
- ??:
n
- the number of bytes to skip- ??:
- the actual number of bytes skipped
- ??:
IOException
- if an I/O error occurs.
-
available
- ??:
available
???InputStream
- ??:
IOException
-
toString
Invokes the delegate'stoString()
method. -
close
- ???:
close
????AutoCloseable
- ???:
close
????Closeable
- ??:
close
???InputStream
- ??:
IOException
- if an I/O error occurs.
-
reset
Invokes the delegate'sreset()
method.- ??:
reset
???InputStream
- ??:
IOException
- if an I/O error occurs.
-
mark
Invokes the delegate'smark(int)
method.- ??:
mark
???InputStream
- ??:
readlimit
- read ahead limit
-
markSupported
Invokes the delegate'smarkSupported()
method.- ??:
markSupported
???InputStream
- ??:
- true if mark is supported, otherwise false
-
isPropagateClose
Indicates whether theclose()
method should propagate to the underlingInputStream
.- ??:
true
if callingclose()
propagates to theclose()
method of the underlying stream orfalse
if it does not.
-
setPropagateClose
Set whether theclose()
method should propagate to the underlingInputStream
.- ??:
propagateClose
-true
if callingclose()
propagates to theclose()
method of the underlying stream orfalse
if it does not.
-