com.hs.mail.io
Class SizeLimitedInputStream
java.lang.Object
java.io.InputStream
com.hs.mail.io.SizeLimitedInputStream
- All Implemented Interfaces:
- Closeable
public class SizeLimitedInputStream
- extends InputStream
Wraps an underlying input stream, limiting the allowable size
of incoming data. The size limit is configured in the conf file,
and when the limit is reached, a MessageSizeException is thrown.
Method Summary |
int |
read()
Overrides the read method of InputStream to call the read() method of the
wrapped input stream. |
int |
read(byte[] b,
int off,
int len)
Overrides the read method of InputStream to call the read() method of the
wrapped input stream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SizeLimitedInputStream
public SizeLimitedInputStream(InputStream in,
long maxmessagesize)
- Constructor for the stream. Wraps an underlying stream.
- Parameters:
in
- InputStream to use as basis for new Stream.maxmessagesize
- Message size limit, in Kilobytes
read
public int read(byte[] b,
int off,
int len)
throws IOException
- Overrides the read method of InputStream to call the read() method of the
wrapped input stream.
- Overrides:
read
in class InputStream
- Returns:
- Returns the number of bytes read.
- Throws:
IOException
- Throws a MessageSizeException, which is a sub-type of IOException
read
public int read()
throws IOException
- Overrides the read method of InputStream to call the read() method of the
wrapped input stream.
- Specified by:
read
in class InputStream
- Returns:
- Returns the int character value of the byte read.
- Throws:
IOException
- Throws a MessageSizeException, which is a sub-type of IOException.
Copyright © 2011. All Rights Reserved.