public class SizedInputStream 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 |
---|
SizedInputStream(InputStream in,
int size)
Creates a new
SizedInputStream that wraps the given input
stream and limits it to a certain size. |
public SizedInputStream(InputStream in, int size)
SizedInputStream
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 int read() throws IOException
read
in class InputStream
IOException
InputStream.read()
public int read(byte[] b) throws IOException
read
in class InputStream
IOException
InputStream.read(byte[])
public int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
IOException
InputStream.read(byte[], int, int)
public long skip(long n) throws IOException
skip
in class InputStream
IOException
InputStream.skip(long)
public int available() throws IOException
available
in class InputStream
IOException
InputStream.available()
public String toString()
toString
in class Object
Object.toString()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
InputStream.close()
public void reset() throws IOException
reset
in class InputStream
IOException
InputStream.reset()
public void mark(int readlimit)
mark
in class InputStream
InputStream.mark(int)
public boolean markSupported()
markSupported
in class InputStream
InputStream.markSupported()
"Copyright © 2006 - 2015 Adobe Systems Incorporated. All Rights Reserved"