Package gaiasky.util.io
Class ByteBufferInputStream
java.lang.Object
java.io.InputStream
gaiasky.util.io.ByteBufferInputStream
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class ByteBufferInputStream
extends java.io.InputStream
An InputStream whose source is a
ByteBuffer
.-
Constructor Summary
Constructors Constructor Description ByteBufferInputStream()
ByteBufferInputStream(int bufferSize)
Creates a stream with a new non-direct buffer of the specified size.ByteBufferInputStream(java.nio.ByteBuffer byteBuffer)
Creates an uninitialized stream that cannot be used untilsetByteBuffer(ByteBuffer)
is called. -
Method Summary
Modifier and Type Method Description int
available()
java.nio.ByteBuffer
getByteBuffer()
int
read()
int
read(byte[] bytes, int offset, int length)
void
setByteBuffer(java.nio.ByteBuffer byteBuffer)
Methods inherited from class java.io.InputStream
close, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
ByteBufferInputStream
public ByteBufferInputStream() -
ByteBufferInputStream
public ByteBufferInputStream(int bufferSize)Creates a stream with a new non-direct buffer of the specified size. The position and limit of the buffer is zero. -
ByteBufferInputStream
public ByteBufferInputStream(java.nio.ByteBuffer byteBuffer)Creates an uninitialized stream that cannot be used untilsetByteBuffer(ByteBuffer)
is called.
-
-
Method Details
-
getByteBuffer
public java.nio.ByteBuffer getByteBuffer() -
setByteBuffer
public void setByteBuffer(java.nio.ByteBuffer byteBuffer) -
read
public int read() throws java.io.IOException- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] bytes, int offset, int length) throws java.io.IOException- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException- Overrides:
available
in classjava.io.InputStream
- Throws:
java.io.IOException
-