public final class DatagramReader extends Object
| Constructor and Description |
|---|
DatagramReader(byte[] byteArray)
Creates a new reader for an array of bytes.
|
DatagramReader(ByteArrayInputStream byteStream)
Creates a new reader for an bytes stream.
|
| Modifier and Type | Method and Description |
|---|---|
int |
bitsLeft()
Gets the number of remaining bits that can be read from the datagram.
|
boolean |
bytesAvailable()
Checks if there are any more bytes available on the stream.
|
boolean |
bytesAvailable(int expectedBytes)
Checks whether a given number of bytes can be read.
|
void |
mark()
Mark current position to be reseted afterwards.
|
int |
read(int numBits)
Reads a sequence of bits from the stream.
|
byte[] |
readBytes(int count)
Reads a sequence of bytes from the stream.
|
byte[] |
readBytesLeft()
Reads the complete sequence of bytes left in the stream.
|
long |
readLong(int numBits)
Reads a sequence of bits from the stream.
|
byte |
readNextByte()
Reads the next byte from the stream.
|
void |
reset()
Reset reader to last mark.
|
public DatagramReader(byte[] byteArray)
byteArray - The byte array to read from.public DatagramReader(ByteArrayInputStream byteStream)
byteStream - The byte stream to read from.NullPointerException - if byte stream is nullpublic void mark()
reset()public void reset()
mark()public long readLong(int numBits)
numBits - The number of bits to read.public int read(int numBits)
numBits - The number of bits to read.public byte[] readBytes(int count)
count - The number of bytes to read.public byte readNextByte()
public byte[] readBytesLeft()
public boolean bytesAvailable()
true if there are bytes left to read,
false otherwise.public boolean bytesAvailable(int expectedBytes)
expectedBytes - the number of bytes.true if the remaining number of bytes in the buffer is at least
expectedBytes.public int bitsLeft()
Copyright © 2019 Eclipse Foundation. All rights reserved.