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
AnInputStreamimplementation based on an underlyingByteBuffersupportingmark.May be utilized as well with a
memory-mappedFileChannelusing a size ≤Integer.MAX_VALUE.
This becomes efficient with files ≥ 10 MiB, depending on the platform and whether the traditional method uses aBufferedInputStreamsupportingmarkincl. 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 intavailable()ByteBuffergetBuffer()voidmark(int unused)This implementation supportsmark.booleanmarkSupported()This implementation supportsmark.intread()intread(byte[] b, int off, int len)intread(ByteBuffer b, int len)voidreset()This implementation supportsmark.longskip(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:
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:
markSupported()
-
reset
public final void reset() throws IOExceptionThis implementation supportsmark.- Overrides:
resetin classInputStream- Throws:
IOException- See Also:
markSupported()
-
skip
public final long skip(long n) throws IOException- 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
public final int read(ByteBuffer b, int len)
-
getBuffer
public final ByteBuffer getBuffer()
-
-