Package com.jogamp.common.nio
Class ByteBufferInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.jogamp.common.nio.ByteBufferInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class ByteBufferInputStream extends InputStream
AnInputStream
implementation based on an underlyingByteBuffer
supportingmark
.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 aBufferedInputStream
supportingmark
incl. it's buffer size.
See test casecom.jogamp.common.nio.TestByteBufferInputStream
.- Since:
- 2.3.0
-
-
Constructor Summary
Constructors Constructor Description ByteBufferInputStream(ByteBuffer buf)
Creates a new byte-buffer input stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
ByteBuffer
getBuffer()
void
mark(int unused)
This implementation supportsmark
.boolean
markSupported()
This implementation supportsmark
.int
read()
int
read(byte[] b, int off, int len)
int
read(ByteBuffer b, int len)
void
reset()
This implementation supportsmark
.long
skip(long n)
-
Methods inherited from class java.io.InputStream
close, nullInputStream, read, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
ByteBufferInputStream
public ByteBufferInputStream(ByteBuffer buf)
Creates a new byte-buffer input stream.- Parameters:
buf
- the underlying byte buffer.
-
-
Method Detail
-
available
public final int available()
- Overrides:
available
in classInputStream
-
markSupported
public final boolean markSupported()
This implementation supportsmark
.- Overrides:
markSupported
in classInputStream
-
mark
public final void mark(int unused)
This implementation supportsmark
.- Overrides:
mark
in classInputStream
- See Also:
markSupported()
-
reset
public final void reset() throws IOException
This implementation supportsmark
.- Overrides:
reset
in classInputStream
- Throws:
IOException
- See Also:
markSupported()
-
skip
public final long skip(long n) throws IOException
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
read
public final int read()
- Specified by:
read
in classInputStream
-
read
public final int read(byte[] b, int off, int len)
- Overrides:
read
in classInputStream
-
read
public final int read(ByteBuffer b, int len)
-
getBuffer
public final ByteBuffer getBuffer()
-
-