Package org.apache.xmlrpc.util
Class LimitedInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.xmlrpc.util.LimitedInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class LimitedInputStream extends java.io.InputStream
A filteringInputStream
for proper handling of theContent-Length
header: It guarantees to return at most a given number of bytes.
-
-
Field Summary
Fields Modifier and Type Field Description private long
available
private java.io.InputStream
in
private long
markedAvailable
-
Constructor Summary
Constructors Constructor Description LimitedInputStream(java.io.InputStream pIn, int pAvailable)
Creates a new instance, reading from the given input stream and returning at most the given number of bytes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
mark(int readlimit)
boolean
markSupported()
int
read()
int
read(byte[] b, int off, int len)
void
reset()
long
skip(long n)
-
-
-
Constructor Detail
-
LimitedInputStream
public LimitedInputStream(java.io.InputStream pIn, int pAvailable)
Creates a new instance, reading from the given input stream and returning at most the given number of bytes.- Parameters:
pIn
- Input stream being read.pAvailable
- Number of bytes available inpIn
.
-
-
Method Detail
-
read
public int read() throws java.io.IOException
- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException
- Overrides:
skip
in classjava.io.InputStream
- Throws:
java.io.IOException
-
mark
public void mark(int readlimit)
- Overrides:
mark
in classjava.io.InputStream
-
reset
public void reset() throws java.io.IOException
- Overrides:
reset
in classjava.io.InputStream
- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classjava.io.InputStream
-
-