Package org.snmp4j.asn1
Class BERInputStream
java.lang.Object
java.io.InputStream
org.snmp4j.asn1.BERInputStream
- All Implemented Interfaces:
 Closeable,AutoCloseable
The 
BERInputStream class wraps a ByteBuffer and
 implements the InputStream abstract class.
 positions in the input stream.- Version:
 - 1.6.1
 - Author:
 - Frank Fock
 
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionintReturns 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.voidclose()Closes this input stream and releases any system resources associated with the stream.intGets the total number of bytes that can be read from this input stream.longGets the current position in the underlyingbuffer.booleanisMarked()Checks whether a mark has been set on the input stream.voidmark(int readlimit) Marks the current position in this input stream.booleanTests if this input stream supports themarkandresetmethods.intread()intread(byte[] b) Reads some number of bytes from the input stream and stores them into the buffer arrayb.intread(byte[] b, int off, int len) Reads up tolenbytes of data from the input stream into an array of bytes.voidreset()Repositions this stream to the position at the time themarkmethod was last called on this input stream.voidsetBuffer(ByteBuffer buf) longskip(long n) Skips over and discardsnbytes of data from this input stream. 
- 
Constructor Details
- 
BERInputStream
 
 - 
 - 
Method Details
- 
getBuffer
 - 
setBuffer
 - 
read
- Specified by:
 readin classInputStream- Throws:
 IOException
 - 
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.- Overrides:
 availablein classInputStream- Returns:
 - the number of bytes that can be read from this input stream without blocking.
 - Throws:
 IOException- if an I/O error occurs.
 - 
close
Closes this input stream and releases any system resources associated with the stream.- Specified by:
 closein interfaceAutoCloseable- Specified by:
 closein interfaceCloseable- Overrides:
 closein classInputStream- Throws:
 IOException- if an I/O error occurs.
 - 
mark
public void mark(int readlimit) Marks the current position in this input stream.- Overrides:
 markin classInputStream- Parameters:
 readlimit- the maximum limit of bytes that can be read before the mark position becomes invalid.
 - 
markSupported
public boolean markSupported()Tests if this input stream supports themarkandresetmethods.- Overrides:
 markSupportedin classInputStream- Returns:
 trueif this stream instance supports the mark and reset methods;falseotherwise.
 - 
read
Reads some number of bytes from the input stream and stores them into the buffer arrayb.- Overrides:
 readin classInputStream- Parameters:
 b- the buffer into which the data is read.- Returns:
 - the total number of bytes read into the buffer, or 
-1is there is no more data because the end of the stream has been reached. - Throws:
 IOException- if an I/O error occurs.
 - 
read
Reads up tolenbytes of data from the input stream into an array of bytes.- Overrides:
 readin classInputStream- Parameters:
 b- the buffer into which the data is read.off- the start offset in arraybat which the data is written.len- the maximum number of bytes to read.- Returns:
 - the total number of bytes read into the buffer, or 
-1if there is no more data because the end of the stream has been reached. - Throws:
 IOException- if an I/O error occurs.
 - 
reset
Repositions this stream to the position at the time themarkmethod was last called on this input stream.- Overrides:
 resetin classInputStream- Throws:
 IOException- if this stream has not been marked or if the mark has been invalidated.
 - 
skip
Skips over and discardsnbytes of data from this input stream.- Overrides:
 skipin classInputStream- Parameters:
 n- the number of bytes to be skipped.- Returns:
 - the actual number of bytes skipped.
 - Throws:
 IOException- if an I/O error occurs.
 - 
getPosition
public long getPosition()Gets the current position in the underlyingbuffer.- Returns:
 buffer.position().
 - 
isMarked
public boolean isMarked()Checks whether a mark has been set on the input stream. This can be used to determine whether the value returned byavailable()is limited by a readlimit set when the mark has been set.- Returns:
 - always 
true. If no mark has been set explicitly, the mark is set to the initial position (i.e. zero). 
 - 
getAvailableBytes
public int getAvailableBytes()Gets the total number of bytes that can be read from this input stream.- Returns:
 - the number of bytes that can be read from this stream.
 
 
 -