|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream net.wimpi.modbus.io.FastByteArrayInputStream
public class FastByteArrayInputStream
This class is a clean room implementation of the ByteArrayInputStream, with enhancements for speed (no synchronization for example).
The idea for such an implementation was originally obtained from Berkeley DB JE, however, this represents a clean-room implementation that is NOT derived from their implementation for license reasons and differs in implementation considerably. For compatibility reasons we have tried to conserve the interface as much as possible.
Constructor Summary | |
---|---|
FastByteArrayInputStream(byte[] buffer)
Creates a new FastByteArrayInputStream instance that allows to read from the given byte array. |
|
FastByteArrayInputStream(byte[] buffer,
int offset,
int length)
Creates a new FastByteArrayInputStream instance that allows to read from the given byte array. |
Method Summary | |
---|---|
int |
available()
Returns the number of bytes that can be read (or skipped over) from this FastByteArrayInputStream. |
void |
close()
The close method for this FastByteArrayInputStream does nothing. |
byte[] |
getBuffer()
Returns the underlying data being read. |
int |
getPosition()
Returns the offset at which data is being read from the buffer. |
void |
mark(int limit)
Marks the current position in this FastByteArrayInputStream. |
boolean |
markSupported()
Tests if this FastByteArrayInputStream supports the mark and reset methods. |
int |
read()
Reads the next byte of data from this input stream. |
int |
read(byte[] toBuf)
|
int |
read(byte[] toBuf,
int offset,
int length)
Reads up to len bytes of data into an array of bytes from this input stream. |
void |
reset()
Re-positions this stream to the position at the time the mark method was last called this FastByteArrayInputStream. |
int |
size()
Returns the size of the buffer being read. |
long |
skip(long n)
Skips over and discards n bytes of data from this input stream. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FastByteArrayInputStream(byte[] buffer)
buffer
- the data to be read.public FastByteArrayInputStream(byte[] buffer, int offset, int length)
buffer
- the data to read.offset
- the byte offset at which to begin reading.length
- the number of bytes to read.Method Detail |
---|
public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] toBuf, int offset, int length) throws IOException
read
in class InputStream
toBuf
- the buffer into which the data is read.offset
- the start offset of the data.length
- the max number of bytes read.
IOException
public int read(byte[] toBuf) throws IOException
read
in class InputStream
IOException
public long skip(long n)
skip
in class InputStream
n
- the number of bytes to be skipped.
public void close()
close
in interface Closeable
close
in class InputStream
public int available()
available
in class InputStream
public void mark(int limit)
reset()
will re-postition this FastByteArrayInputStream
at the last marked position so that subsequent reads re-read the same bytes.
mark
in class InputStream
limit
- a read limit that invalidates the mark if passed.public boolean markSupported()
markSupported
in class InputStream
public void reset() throws IOException
reset
in class InputStream
IOException
- if the readlimit was exceeded.public byte[] getBuffer()
public int getPosition()
public int size()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |