public class ByteBufferBackedInputStream extends InputStream
InputStream backed by ByteBuffer, implementing following
functionality (on top of what's required by InputStream)
| Constructor and Description |
|---|
ByteBufferBackedInputStream(byte[] array) |
ByteBufferBackedInputStream(byte[] array,
int offset,
int length) |
ByteBufferBackedInputStream(ByteBuffer buf) |
| Modifier and Type | Method and Description |
|---|---|
int |
copyFrom(long pos,
byte[] targetBuffer,
int offset,
int length)
Copies at most
length bytes starting from position pos into the target
buffer with provided offset. |
int |
getPosition()
Returns current position of the stream
|
int |
read() |
int |
read(byte[] bytes,
int offset,
int length) |
void |
seek(long pos)
Seeks to a position w/in the stream
NOTE: Position is relative to the start of the stream (ie its absolute w/in this stream),
with following invariant being assumed:
|
available, close, mark, markSupported, read, reset, skippublic ByteBufferBackedInputStream(ByteBuffer buf)
public ByteBufferBackedInputStream(byte[] array)
public ByteBufferBackedInputStream(byte[] array,
int offset,
int length)
public int read()
read in class InputStreampublic int read(@Nonnull byte[] bytes, int offset, int length)
read in class InputStreampublic int getPosition()
public void seek(long pos)
0 <= pos <= length (of the stream)
This method is NOT thread-safepos - target position to seek to w/in the holding bufferpublic int copyFrom(long pos,
byte[] targetBuffer,
int offset,
int length)
length bytes starting from position pos into the target
buffer with provided offset. Returns number of bytes copied from the backing buffer
NOTE: This does not change the current position of the stream and is thread-safepos - absolute position w/in stream to read fromtargetBuffer - target buffer to copy intooffset - target buffer offset to copy atlength - length of the sequence to copyCopyright © 2024 The Apache Software Foundation. All rights reserved.