|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream infoservice.mailsystem.central.server.util.LimitedLengthInputStream
public class LimitedLengthInputStream
This class is the implementation for an InputStream where only a specified number of bytes can be read from.
Field Summary | |
---|---|
private long |
m_readLimit
Stores the maximum number of bytes which can still be read from the stream. |
private java.io.InputStream |
m_underlyingStream
Stores the underlying stream from which the data are read. |
Constructor Summary | |
---|---|
LimitedLengthInputStream(java.io.InputStream a_underlyingStream,
long a_maximumLength)
Creates an input stream with a limited length. |
Method Summary | |
---|---|
int |
available()
Returns the number of bytes which can be read from this input stream without blocking. |
void |
close()
Closes the underlying stream. |
long |
getRemainingBytes()
Returns the number of remaining bytes for the read limit. |
int |
read()
Reads one byte from the underlying InputStream. |
int |
read(byte[] a_buffer)
Reads bytes into a portion of an array. |
int |
read(byte[] a_buffer,
int a_offset,
int a_length)
Reads bytes into a portion of an array. |
Methods inherited from class java.io.InputStream |
---|
mark, markSupported, reset, skip |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.io.InputStream m_underlyingStream
private long m_readLimit
Constructor Detail |
---|
public LimitedLengthInputStream(java.io.InputStream a_underlyingStream, long a_maximumLength)
a_underlyingStream
- The stream to read the data from. If this is null, this constructor
will throw a NullPointerException.a_maximumLength
- The maximum number of bytes to read from the underlying stream. This
value needs to be >= -1. A value of -1 disables the limit end enables
reading until the end of the underlying stream is reached.Method Detail |
---|
public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
- If an I/O error occurs.public int read(byte[] a_buffer) throws java.io.IOException
read
in class java.io.InputStream
a_buffer
- The destination buffer.
-1
if the end of the stream was reached or
the read limit is already exhausted and no byte could be read.
java.io.IOException
- If an I/O error occurs.public int read(byte[] a_buffer, int a_offset, int a_length) throws java.io.IOException
read
in class java.io.InputStream
a_buffer
- The destination buffer.a_offset
- The offset in the destination buffer at which to start storing bytes.a_length
- The maximum number of bytes to read.
-1
if the end of the stream was reached or
the read limit is already exhausted and no byte could be read.
java.io.IOException
- If an I/O error occurs.public int available() throws java.io.IOException
available
in class java.io.InputStream
java.io.IOException
- If an I/O error occurs.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.InputStream
java.io.IOException
- If an I/O error occurs.public long getRemainingBytes()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |