public class ResizingPipedInputStream
extends java.io.InputStream
| Constructor and Description |
|---|
ResizingPipedInputStream(int initialBufferSize)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
int |
capacity() |
void |
copyTo(java.io.OutputStream outputStream)
Copies all of the available bytes in the buffer without changing the number of bytes available to subsequent
reads.
|
int |
read() |
int |
read(byte[] b,
int off,
int len) |
void |
receive(byte[] b)
Buffers `b.length` additional bytes.
|
void |
receive(byte[] b,
int off,
int len)
Buffers `len` additional bytes, growing the buffer if it is already full or if it would become full
by writing `len` bytes.
|
int |
receive(java.io.InputStream input,
int len)
Buffers up to `len` additional bytes, growing the buffer if it is already full or if it would become full
by writing `len` bytes.
|
void |
receive(int b)
Buffers a single additional byte, growing the buffer if it is already full.
|
long |
skip(long n)
Skips up to `n` buffered bytes.
|
public ResizingPipedInputStream(int initialBufferSize)
initialBufferSize - the initial size of the buffer. When full, the buffer will grow by this
many bytes. The buffer always stores bytes contiguously, so growth requires
allocation of a new buffer capable of holding the new capacity and copying of the
existing bytes into the new buffer. As such, a size should be chosen carefully
such that growth is expected to occur rarely, if ever.public void receive(int b)
b - the byte to buffer.public void receive(byte[] b,
int off,
int len)
b - the bytes to buffer.off - the offset into `b` that points to the first byte to buffer.len - the number of bytes to buffer.public void receive(byte[] b)
b - the bytes to buffer.receive(byte[], int, int)public int receive(java.io.InputStream input,
int len)
throws java.io.IOException
InputStream.read(byte[], int, int) blocks when trying to read `len` bytes. If this is not desired,
the caller should ensure that the given `InputStream` has at least `len` bytes available before calling
this method or provide an InputStream implementation that does not block.input - the source of the bytes.len - the number of bytes to attempt to write.InputStream.read(byte[], int, int) returns less than `len`.java.io.IOException - if thrown by the given `InputStream` during read, except for EOFException. If an
EOFException is thrown by the `InputStream`, it will be caught and this method will return the number of bytes
that were received before the exception was thrown.public int read(byte[] b,
int off,
int len)
NOTE: This method adheres to the documented behavior of InputStream.read(byte[], int, int)
except that it never blocks. If a read is attempted before the first write,
this method will return -1.
read in class java.io.InputStreampublic void copyTo(java.io.OutputStream outputStream)
throws java.io.IOException
outputStream - stream to which the bytes will be copied.java.io.IOException - if thrown by OutputStream.write(byte[], int, int).public long skip(long n)
skip in class java.io.InputStreamn - the number of bytes to skip.public int available()
NOTE: This method adheres to the documented behavior of InputStream.available()
except that it always returns the exact number of bytes that are available in the
buffer.
available in class java.io.InputStreampublic int read()
NOTE: This method adheres to the documented behavior of InputStream.read(byte[], int, int)
except that it never blocks. If a read is attempted before the first write,
this method will return -1.
read in class java.io.InputStreampublic int capacity()