public class ByteBufferInputStream extends InputStream
InputStream that reads from an existing ByteBuffer.
Will reposition the buffer at construction, and read sequentially from that
point. Attempting to read past the buffer's limit will return end-of-file.
Warnings:
Because this class explicitly repositions the buffer, you should not create
two instances around the same buffer; slice() the buffer
instead. Instances of this class are only as thread-safe as the underlying
buffer (and the JavaDocs don't have much to say about that).
| Constructor and Description |
|---|
ByteBufferInputStream(ByteBuffer buf)
Creates an instance that positions the stream at the start of the
buffer.
|
ByteBufferInputStream(ByteBuffer buf,
int off)
Creates an instance that positions the stream at the specified offset.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
void |
close() |
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
void |
reset() |
long |
skip(long n) |
public ByteBufferInputStream(ByteBuffer buf)
public ByteBufferInputStream(ByteBuffer buf, int off)
public int available()
throws IOException
available in class InputStreamIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOExceptionpublic void mark(int readlimit)
mark in class InputStreampublic boolean markSupported()
markSupported in class InputStreampublic int read()
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] b)
throws IOException
read in class InputStreamIOExceptionpublic void reset()
throws IOException
reset in class InputStreamIOExceptionpublic long skip(long n)
throws IOException
skip in class InputStreamIOException