public class WrappedByteArrayInputStream extends ByteArrayInputStream implements DuplicatableInputStream
Basic extension to ByteArrayInputStream
that lets you create duplicate
streams from the same underlying byte buffer.
buf, count, mark, pos
Constructor and Description |
---|
WrappedByteArrayInputStream(byte[] buf)
Create a new stream from the given buffer.
|
WrappedByteArrayInputStream(byte[] buf,
int offset,
int length)
Create a new stream from the given buffer.
|
Modifier and Type | Method and Description |
---|---|
InputStream |
duplicate()
Produces a duplicate stream of the source (from its start) that can be used in parallel
to the original stream (ie, thread safe).
|
long |
length()
Returns the length of the underlying buffer (ie, the length of this stream).
|
available, close, mark, markSupported, read, read, reset, skip
read
public WrappedByteArrayInputStream(byte[] buf)
Create a new stream from the given buffer.
buf
- The byte buffer.public WrappedByteArrayInputStream(byte[] buf, int offset, int length)
Create a new stream from the given buffer.
buf
- The byte buffer.offset
- The offset in the buffer of the first byte to read.length
- The maximum number of bytes to read from the buffer.public long length()
Returns the length of the underlying buffer (ie, the length of this stream).
public InputStream duplicate()
DuplicatableInputStream
Produces a duplicate stream of the source (from its start) that can be used in parallel to the original stream (ie, thread safe).
duplicate
in interface DuplicatableInputStream
Copyright © 2016–2022. All rights reserved.