public class BoundedInputStream
extends java.io.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. import From poi
构造器和说明 |
---|
BoundedInputStream(java.io.InputStream in)
Creates a new
BoundedInputStream that wraps the given input
stream and is unlimited. |
BoundedInputStream(java.io.InputStream in,
long size)
Creates a new
BoundedInputStream that wraps the given input
stream and limits it to a certain size. |
限定符和类型 | 方法和说明 |
---|---|
int |
available() |
void |
close()
|
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. |
java.lang.String |
toString()
Invokes the delegate's
toString() method. |
public BoundedInputStream(java.io.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(java.io.InputStream in)
BoundedInputStream
that wraps the given input
stream and is unlimited.in
- The wrapped input streampublic int read() throws java.io.IOException
read()
method if
the current position is less than the limit.read
在类中 java.io.InputStream
java.io.IOException
- if an I/O error occurspublic int read(byte[] b) throws java.io.IOException
read(byte[])
method.read
在类中 java.io.InputStream
b
- the buffer to read the bytes intojava.io.IOException
- if an I/O error occurspublic int read(byte[] b, int off, int len) throws java.io.IOException
read(byte[], int, int)
method.read
在类中 java.io.InputStream
b
- the buffer to read the bytes intooff
- The start offsetlen
- The number of bytes to readjava.io.IOException
- if an I/O error occurspublic long skip(long n) throws java.io.IOException
skip(long)
method.skip
在类中 java.io.InputStream
n
- the number of bytes to skipjava.io.IOException
- if an I/O error occurspublic int available() throws java.io.IOException
available
在类中 java.io.InputStream
java.io.IOException
public java.lang.String toString()
toString()
method.toString
在类中 java.lang.Object
toString()
public void close() throws java.io.IOException
close
在接口中 java.io.Closeable
close
在接口中 java.lang.AutoCloseable
close
在类中 java.io.InputStream
java.io.IOException
- if an I/O error occurspublic void reset() throws java.io.IOException
reset()
method.reset
在类中 java.io.InputStream
java.io.IOException
- if an I/O error occurspublic void mark(int readlimit)
mark(int)
method.mark
在类中 java.io.InputStream
readlimit
- read ahead limitpublic boolean markSupported()
markSupported()
method.markSupported
在类中 java.io.InputStream
public 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.