public class MaxLengthRecordingInputStream extends java.io.FilterInputStream
InputStream with a maximum amount of bytes available to read.
When the stream is closed the remaining bytes are left untouched.| Modifier and Type | Field and Description |
|---|---|
protected long |
available
Maximum remaining bytes available.
|
protected java.io.ByteArrayOutputStream |
record
Output stream used to keep a record of data read.
|
protected byte[] |
skip_read_buffer
Read buffer used by the skip method.
|
static int |
SKIP_READ_BUFFER_SIZE
Buffer size to use when read skipping.
|
| Constructor and Description |
|---|
MaxLengthRecordingInputStream(java.io.InputStream in,
long available)
Create a new input stream with a maximum number of bytes available from
the underlying stream.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
void |
close()
Closing will only close the recording and not call the parent's close
method.
|
byte[] |
getRecording()
Return the bytes recorded by the stream.
|
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
void |
reset() |
long |
skip(long n) |
public static final int SKIP_READ_BUFFER_SIZE
protected byte[] skip_read_buffer
protected java.io.ByteArrayOutputStream record
protected long available
public MaxLengthRecordingInputStream(java.io.InputStream in, long available)
in - the input stream to wrapavailable - maximum number of bytes available through this streampublic byte[] getRecording()
public void close() throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.FilterInputStreamjava.io.IOException - if an I/O error occurs while closing streampublic int available() throws java.io.IOException
available in class java.io.FilterInputStreamjava.io.IOExceptionpublic boolean markSupported()
markSupported in class java.io.FilterInputStreampublic void mark(int readlimit)
mark in class java.io.FilterInputStreampublic void reset() throws java.io.IOException
reset in class java.io.FilterInputStreamjava.io.IOExceptionpublic int read() throws java.io.IOException
read in class java.io.FilterInputStreamjava.io.IOExceptionpublic int read(byte[] b) throws java.io.IOException
read in class java.io.FilterInputStreamjava.io.IOExceptionpublic int read(byte[] b, int off, int len) throws java.io.IOException
read in class java.io.FilterInputStreamjava.io.IOExceptionpublic long skip(long n) throws java.io.IOException
skip in class java.io.FilterInputStreamjava.io.IOExceptionCopyright © 2011–2023. All rights reserved.