public class BERInputStream
extends java.io.InputStream
BERInputStream
class wraps a ByteBuffer
and
implements the InputStream
abstract class.
positions in the input stream.Modifier and Type | Field and Description |
---|---|
private java.nio.ByteBuffer |
buffer |
Constructor and Description |
---|
BERInputStream(java.nio.ByteBuffer buffer) |
Modifier and Type | Method and Description |
---|---|
int |
available()
Returns the number of bytes that can be read (or skipped over) from this
input stream without blocking by the next caller of a method for this input
stream.
|
void |
close()
Closes this input stream and releases any system resources associated with
the stream.
|
int |
getAvailableBytes()
Gets the total number of bytes that can be read from this input stream.
|
java.nio.ByteBuffer |
getBuffer() |
long |
getPosition()
Gets the current position in the underlying
buffer . |
boolean |
isMarked()
Checks whether a mark has been set on the input stream.
|
void |
mark(int readlimit)
Marks the current position in this input stream.
|
boolean |
markSupported()
Tests if this input stream supports the
mark and
reset methods. |
int |
read() |
int |
read(byte[] b)
Reads some number of bytes from the input stream and stores them into the
buffer array
b . |
int |
read(byte[] b,
int off,
int len)
Reads up to
len bytes of data from the input stream into an
array of bytes. |
void |
reset()
Repositions this stream to the position at the time the
mark
method was last called on this input stream. |
void |
setBuffer(java.nio.ByteBuffer buf) |
long |
skip(long n)
Skips over and discards
n bytes of data from this input stream. |
public java.nio.ByteBuffer getBuffer()
public void setBuffer(java.nio.ByteBuffer buf)
public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int available() throws java.io.IOException
available
in class java.io.InputStream
java.io.IOException
- if an I/O error occurs.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.InputStream
java.io.IOException
- if an I/O error occurs.public void mark(int readlimit)
mark
in class java.io.InputStream
readlimit
- the maximum limit of bytes that can be read before the
mark position becomes invalid.public boolean markSupported()
mark
and
reset
methods.markSupported
in class java.io.InputStream
true
if this stream instance supports the mark and
reset methods; false
otherwise.public int read(byte[] b) throws java.io.IOException
b
.read
in class java.io.InputStream
b
- the buffer into which the data is read.-1
is there is no more data because the end of the stream has been reached.java.io.IOException
- if an I/O error occurs.public int read(byte[] b, int off, int len) throws java.io.IOException
len
bytes of data from the input stream into an
array of bytes.read
in class java.io.InputStream
b
- the buffer into which the data is read.off
- the start offset in array b
at which the data is
written.len
- the maximum number of bytes to read.-1
if there is no more data because the end of the stream has been reached.java.io.IOException
- if an I/O error occurs.public void reset() throws java.io.IOException
mark
method was last called on this input stream.reset
in class java.io.InputStream
java.io.IOException
- if this stream has not been marked or if the mark has
been invalidated.public long skip(long n) throws java.io.IOException
n
bytes of data from this input stream.skip
in class java.io.InputStream
n
- the number of bytes to be skipped.java.io.IOException
- if an I/O error occurs.public long getPosition()
buffer
.buffer.position()
.public boolean isMarked()
available()
is limited
by a readlimit set when the mark has been set.true
. If no mark has been set explicitly, the mark
is set to the initial position (i.e. zero).public int getAvailableBytes()