Package com.jalios.io
Class SizeLimitInputStream
- java.lang.Object
 - 
- java.io.InputStream
 - 
- java.io.FilterInputStream
 - 
- com.jalios.io.SizeLimitInputStream
 
 
 
 
- 
- All Implemented Interfaces:
 java.io.Closeable,java.lang.AutoCloseable
public class SizeLimitInputStream extends java.io.FilterInputStreamInputStream Filter that will throw an SizeLimitExceededException if the wrapped stream exceed the byte count specified in constructor.- Version:
 - $Revision: 27751 $
 
 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description classSizeLimitInputStream.SizeLimitExceededExceptionSignals that a size limit has been reach during an I/O operation. 
- 
Field Summary
Fields Modifier and Type Field Description static java.lang.StringREVISION 
- 
Constructor Summary
Constructors Constructor Description SizeLimitInputStream(java.io.InputStream in, long limit)Constructs a new SizeLimitInputStreamFilter. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intread()Reads the next byte of data adding to the count of bytes received if a byte is successfully read.intread(byte[] b)Reads a number of bytes into the byte array, keeping count of the number read.intread(byte[] b, int off, int len)Reads a number of bytes into the byte array at a specific offset, keeping count of the number read.longskip(long length)Skips the stream over the specified number of bytes, adding the skipped amount to the count. 
 - 
 
- 
- 
Field Detail
- 
REVISION
public static final java.lang.String REVISION
- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Method Detail
- 
read
public int read(byte[] b) throws java.io.IOExceptionReads a number of bytes into the byte array, keeping count of the number read.- Overrides:
 readin classjava.io.FilterInputStream- Parameters:
 b- the buffer into which the data is read, not null- Returns:
 - the total number of bytes read into the buffer, -1 if end of stream
 - Throws:
 java.io.IOException- if an I/O error occurs- See Also:
 InputStream.read(byte[])
 
- 
read
public int read(byte[] b, int off, int len) throws java.io.IOExceptionReads a number of bytes into the byte array at a specific offset, keeping count of the number read.- Overrides:
 readin classjava.io.FilterInputStream- Parameters:
 b- the buffer into which the data is read, not nulloff- the start offset in the bufferlen- the maximum number of bytes to read- Returns:
 - the total number of bytes read into the buffer, -1 if end of stream
 - Throws:
 java.io.IOException- if an I/O error occurs- See Also:
 InputStream.read(byte[], int, int)
 
- 
read
public int read() throws java.io.IOExceptionReads the next byte of data adding to the count of bytes received if a byte is successfully read.- Overrides:
 readin classjava.io.FilterInputStream- Returns:
 - the byte read, -1 if end of stream
 - Throws:
 java.io.IOException- if an I/O error occurs- See Also:
 InputStream.read()
 
- 
skip
public long skip(long length) throws java.io.IOExceptionSkips the stream over the specified number of bytes, adding the skipped amount to the count.- Overrides:
 skipin classjava.io.FilterInputStream- Parameters:
 length- the number of bytes to skip- Returns:
 - the actual number of bytes skipped
 - Throws:
 java.io.IOException- if an I/O error occurs- See Also:
 InputStream.skip(long)
 
 - 
 
 -