public class ByteBufferInputStream extends InputStream
InputStream
implementation based on an underlying ByteBuffer
supporting mark
.
May be utilized as well with a memory-mapped
FileChannel
using a size ≤ Integer.MAX_VALUE
.
This becomes efficient with files ≥ 10 MiB, depending on the platform
and whether the traditional method uses a BufferedInputStream
supporting mark
incl. it's buffer size.
See test case com.jogamp.common.nio.TestByteBufferInputStream
.
Constructor and Description |
---|
ByteBufferInputStream(ByteBuffer buf)
Creates a new byte-buffer input stream.
|
Modifier and Type | Method and Description |
---|---|
int |
available() |
ByteBuffer |
getBuffer() |
void |
mark(int unused)
This implementation supports
mark . |
boolean |
markSupported()
This implementation supports
mark . |
int |
read() |
int |
read(byte[] b,
int off,
int len) |
int |
read(ByteBuffer b,
int len) |
void |
reset()
This implementation supports
mark . |
long |
skip(long n) |
close, read
public ByteBufferInputStream(ByteBuffer buf)
buf
- the underlying byte buffer.public final int available()
available
in class InputStream
public final boolean markSupported()
mark
.
markSupported
in class InputStream
public final void mark(int unused)
mark
.
mark
in class InputStream
markSupported()
public final void reset() throws IOException
mark
.
reset
in class InputStream
IOException
markSupported()
public final long skip(long n) throws IOException
skip
in class InputStream
IOException
public final int read()
read
in class InputStream
public final int read(byte[] b, int off, int len)
read
in class InputStream
public final int read(ByteBuffer b, int len)
public final ByteBuffer getBuffer()