public class CircularInputStream
extends java.io.InputStream
InputStream
that repeats provided bytes for given target byte count.
Closing this input stream has no effect. The methods in this class can be called after the stream has been closed
without generating an IOException
.
InfiniteCircularInputStream
Modifier and Type | Field and Description |
---|---|
private long |
byteCount |
private int |
position |
private byte[] |
repeatedContent |
private long |
targetByteCount |
Constructor and Description |
---|
CircularInputStream(byte[] repeatContent,
long targetByteCount)
Constructs an instance from the specified array of bytes.
|
Modifier and Type | Method and Description |
---|---|
int |
read() |
private static byte[] |
validate(byte[] repeatContent)
Throws an
IllegalArgumentException if the input contains -1. |
private long byteCount
private int position
private final byte[] repeatedContent
private final long targetByteCount
public CircularInputStream(byte[] repeatContent, long targetByteCount)
repeatContent
- Input buffer to be repeated this buffer is not copied.targetByteCount
- How many bytes the read. A negative number means an infinite target count.