Class LimitedInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- org.apache.commons.fileupload.util.LimitedInputStream
-
-
Constructor Summary
Constructors Constructor Description LimitedInputStream(java.io.InputStream inputStream, long pSizeMax)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes this input stream and releases any system resources associated with the stream.boolean
isClosed()
Returns, whether this stream is already closed.int
read()
Reads the next byte of data from this input stream.int
read(byte[] b, int off, int len)
Reads up tolen
bytes of data from this input stream into an array of bytes.-
Methods inherited from class java.io.FilterInputStream
available, mark, markSupported, read, reset, skip
-
-
-
-
Constructor Detail
-
LimitedInputStream
public LimitedInputStream(java.io.InputStream inputStream, long pSizeMax)
Creates a new instance.- Parameters:
inputStream
- The input stream, which shall be limited.pSizeMax
- The limit; no more than this number of bytes shall be returned by the source stream.
-
-
Method Detail
-
read
public int read() throws java.io.IOException
Reads the next byte of data from this input stream. The value byte is returned as anint
in the range0
to255
. If no byte is available because the end of the stream has been reached, the value-1
is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.This method simply performs
in.read()
and returns the result.- Overrides:
read
in classjava.io.FilterInputStream
- Returns:
- the next byte of data, or
-1
if the end of the stream is reached. - Throws:
java.io.IOException
- if an I/O error occurs.- See Also:
FilterInputStream.in
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException
Reads up tolen
bytes of data from this input stream into an array of bytes. Iflen
is not zero, the method blocks until some input is available; otherwise, no bytes are read and0
is returned.This method simply performs
in.read(b, off, len)
and returns the result.- Overrides:
read
in classjava.io.FilterInputStream
- Parameters:
b
- the buffer into which the data is read.off
- The start offset in the destination arrayb
.len
- the maximum number of bytes read.- Returns:
- the total number of bytes read into the buffer, or
-1
if there is no more data because the end of the stream has been reached. - Throws:
java.lang.NullPointerException
- Ifb
isnull
.java.lang.IndexOutOfBoundsException
- Ifoff
is negative,len
is negative, orlen
is greater thanb.length - off
java.io.IOException
- if an I/O error occurs.- See Also:
FilterInputStream.in
-
isClosed
public boolean isClosed() throws java.io.IOException
Returns, whether this stream is already closed.
-
close
public void close() throws java.io.IOException
Closes this input stream and releases any system resources associated with the stream. This method simply performsin.close()
.
-
-