public class BERInputStream extends InputStream
BERInputStream
class wraps a ByteBuffer
and
implements the InputStream
abstract class.
positions in the input stream.Constructor and Description |
---|
BERInputStream(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.
|
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(ByteBuffer buf) |
long |
skip(long n)
Skips over and discards
n bytes of data from this input stream. |
public BERInputStream(ByteBuffer buffer)
public ByteBuffer getBuffer()
public void setBuffer(ByteBuffer buf)
public int read() throws IOException
read
in class InputStream
IOException
public int available() throws IOException
available
in class InputStream
IOException
- if an I/O error occurs.public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
- if an I/O error occurs.public void mark(int readlimit)
mark
in class 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 InputStream
true
if this stream instance supports the mark and
reset methods; false
otherwise.public int read(byte[] b) throws IOException
b
.read
in class 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.IOException
- if an I/O error occurs.public int read(byte[] b, int off, int len) throws IOException
len
bytes of data from the input stream into an
array of bytes.read
in class 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.IOException
- if an I/O error occurs.public void reset() throws IOException
mark
method was last called on this input stream.reset
in class InputStream
IOException
- if this stream has not been marked or if the mark has
been invalidated.public long skip(long n) throws IOException
n
bytes of data from this input stream.skip
in class InputStream
n
- the number of bytes to be skipped.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()
Copyright © 2020 SNMP4J.org. All rights reserved.