public class SizedInputStream
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.
| Constructor and Description |
|---|
SizedInputStream(java.io.InputStream in,
int size)
Creates a new
SizedInputStream that wraps the given input
stream and limits it to a certain size. |
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
void |
close() |
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
void |
reset() |
long |
skip(long n) |
java.lang.String |
toString() |
public SizedInputStream(java.io.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 java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionInputStream.read()public int read(byte[] b)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionInputStream.read(byte[])public int read(byte[] b,
int off,
int len)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionInputStream.read(byte[], int, int)public long skip(long n)
throws java.io.IOException
skip in class java.io.InputStreamjava.io.IOExceptionInputStream.skip(long)public int available()
throws java.io.IOException
available in class java.io.InputStreamjava.io.IOExceptionInputStream.available()public java.lang.String toString()
toString in class java.lang.ObjectObject.toString()public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.InputStreamjava.io.IOExceptionInputStream.close()public void reset()
throws java.io.IOException
reset in class java.io.InputStreamjava.io.IOExceptionInputStream.reset()public void mark(int readlimit)
mark in class java.io.InputStreamInputStream.mark(int)public boolean markSupported()
markSupported in class java.io.InputStreamInputStream.markSupported()"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"