public class SequentialInputStream
extends java.io.InputStream
InputStream that allows appending data to the stream.| Constructor and Description |
|---|
SequentialInputStream()
Create a new SequentialInputStream with default initial capacity and growth factor.
|
SequentialInputStream(float growthFactor)
Create a new SequentialInputStream with the given growth factor and default initial capacity.
|
SequentialInputStream(int initialCapacity)
Create a new SequentialInputStream with the given initial capacity and default growth factor.
|
SequentialInputStream(int initialCapacity,
float growthFactor)
Create a new SequentialInputStream with the given initial capacity and growth factor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
append(byte[] bytes)
Append data to the stream.
If the internal buffer is full, it will be resized according to the growth factor. |
void |
close()
Close the stream.
Any blocked read operations will be unblocked and return -1 if no more data is available. |
void |
close(java.lang.Throwable error)
Close the stream with an error.
Any blocked read operations will be unblocked and throw an IOException with the given error as cause. |
boolean |
isClosed() |
int |
read()
Read a single byte from the stream.
This method will block if no data is available until new data is appended or the stream is closed. |
int |
read(byte[] b,
int off,
int len)
Read bytes from the stream into the given buffer.
This method will block if no data is available until new data is appended or the stream is closed. |
public SequentialInputStream()
public SequentialInputStream(int initialCapacity)
initialCapacity - The initial capacity of the internal buffer (must be >= 0)public SequentialInputStream(float growthFactor)
growthFactor - The growth factor of the internal buffer when it needs to grow (must be >= 1)public SequentialInputStream(int initialCapacity,
float growthFactor)
initialCapacity - The initial capacity of the internal buffer (must be >= 0)growthFactor - The growth factor of the internal buffer when it needs to grow (must be >= 1)public boolean isClosed()
public void append(byte[] bytes)
bytes - The data to appendjava.lang.NullPointerException - If bytes is nulljava.lang.IllegalStateException - If the stream is closedpublic int read()
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOException - If an I/O error occurspublic int read(@Nonnull
byte[] b,
int off,
int len)
throws java.io.IOException
read in class java.io.InputStreamb - The buffer into which the data is readoff - The start offset in array b at which the data is writtenlen - The maximum number of bytes to readjava.io.IOException - If an I/O error occurspublic void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.InputStreampublic void close(java.lang.Throwable error)
error - The error that caused the stream to close