Package com.jogamp.common.nio
Class ByteBufferInputStream
java.lang.Object
java.io.InputStream
com.jogamp.common.nio.ByteBufferInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
An
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.
- Since:
- 2.3.0
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new byte-buffer input stream. -
Method Summary
Modifier and TypeMethodDescriptionfinal intfinal ByteBufferfinal voidmark(int unused) This implementation supportsmark.final booleanThis implementation supportsmark.final intread()final intread(byte[] b, int off, int len) final intread(ByteBuffer b, int len) final voidreset()This implementation supportsmark.final longskip(long n) Methods inherited from class java.io.InputStream
close, nullInputStream, read, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
ByteBufferInputStream
Creates a new byte-buffer input stream.- Parameters:
buf- the underlying byte buffer.
-
-
Method Details
-
available
public final int available()- Overrides:
availablein classInputStream
-
markSupported
public final boolean markSupported()This implementation supportsmark.- Overrides:
markSupportedin classInputStream
-
mark
public final void mark(int unused) This implementation supportsmark.- Overrides:
markin classInputStream- See Also:
-
reset
This implementation supportsmark.- Overrides:
resetin classInputStream- Throws:
IOException- See Also:
-
skip
- Overrides:
skipin classInputStream- Throws:
IOException
-
read
public final int read()- Specified by:
readin classInputStream
-
read
public final int read(byte[] b, int off, int len) - Overrides:
readin classInputStream
-
read
-
getBuffer
-