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, readpublic ByteBufferInputStream(ByteBuffer buf)
buf - the underlying byte buffer.public final int available()
available in class InputStreampublic final boolean markSupported()
mark.
markSupported in class InputStreampublic final void mark(int unused)
mark.
mark in class InputStreammarkSupported()public final void reset()
throws IOException
mark.
reset in class InputStreamIOExceptionmarkSupported()public final long skip(long n)
throws IOException
skip in class InputStreamIOExceptionpublic final int read()
read in class InputStreampublic final int read(byte[] b,
int off,
int len)
read in class InputStreampublic final int read(ByteBuffer b, int len)
public final ByteBuffer getBuffer()