Package com.nimbusds.jose.util
Class BoundedInputStream
java.lang.Object
java.io.InputStream
com.nimbusds.jose.util.BoundedInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
Size-bounded input stream. Adapted from Apache Commons IO. Throws an
IOException
if the input size limit is exceeded.- Version:
- 2016-11-28
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new unbounded input stream.BoundedInputStream
(InputStream in, long size) Creates a new bounded input stream. -
Method Summary
Modifier and TypeMethodDescriptionint
void
close()
long
Returns the maximum number of bytes to return.boolean
Indicates whether theclose()
method should propagate to the underling InputStream.void
mark
(int readlimit) boolean
int
read()
int
read
(byte[] b) int
read
(byte[] b, int off, int len) void
reset()
void
setPropagateClose
(boolean propagateClose) Set whether theclose()
method should propagate to the underling InputStream.long
skip
(long n) toString()
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
BoundedInputStream
Creates a new bounded input stream.- Parameters:
in
- The input stream to wrap.size
- The maximum number of bytes to return, -1 if no limit.
-
BoundedInputStream
Creates a new unbounded input stream.- Parameters:
in
- The input stream to wrap.
-
-
Method Details
-
getLimitBytes
Returns the maximum number of bytes to return.- Returns:
- The maximum number of bytes to return, -1 if no limit.
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
skip
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
available
- Overrides:
available
in classInputStream
- Throws:
IOException
-
toString
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
reset
- Overrides:
reset
in classInputStream
- Throws:
IOException
-
mark
- Overrides:
mark
in classInputStream
-
markSupported
- Overrides:
markSupported
in classInputStream
-
isPropagateClose
Indicates whether theclose()
method should propagate to the underling InputStream. -
setPropagateClose
Set whether theclose()
method should propagate to the underling InputStream.
-