public class DataInput
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int |
bufferPosition |
private byte[] |
inputBuffer |
Constructor and Description |
---|
DataInput(byte[] buffer)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
getPosition()
Returns the current position.
|
java.lang.String |
getString()
Returns the buffer as an ISO-8859-1 string.
|
boolean |
hasRemaining()
Determines if there are any bytes left to read or not.
|
int |
length() |
private int |
peek(int offset) |
int |
peekUnsignedByte(int offset)
Peeks one single unsigned byte from the buffer.
|
private int |
read() |
byte |
readByte()
Read one single byte from the buffer.
|
byte[] |
readBytes(int length)
Read a number of single byte values from the buffer.
|
int |
readInt()
Read one single int (4 bytes) from the buffer.
|
short |
readShort()
Read one single short value from the buffer.
|
int |
readUnsignedByte()
Read one single unsigned byte from the buffer.
|
int |
readUnsignedShort()
Read one single unsigned short (2 bytes) value from the buffer.
|
void |
setPosition(int position)
Sets the current position to the given value.
|
public DataInput(byte[] buffer)
buffer
- the buffer to be readpublic boolean hasRemaining()
public int getPosition()
public void setPosition(int position)
position
- the given positionpublic java.lang.String getString() throws java.io.IOException
java.io.IOException
- if an error occurs during readingpublic byte readByte() throws java.io.IOException
java.io.IOException
- if an error occurs during readingpublic int readUnsignedByte() throws java.io.IOException
java.io.IOException
- if an error occurs during readingpublic int peekUnsignedByte(int offset) throws java.io.IOException
java.io.IOException
- if an error occurs during readingpublic short readShort() throws java.io.IOException
java.io.IOException
- if an error occurs during readingpublic int readUnsignedShort() throws java.io.IOException
java.io.IOException
- if an error occurs during readingpublic int readInt() throws java.io.IOException
java.io.IOException
- if an error occurs during readingpublic byte[] readBytes(int length) throws java.io.IOException
length
- the number of bytes to be readjava.io.IOException
- if an error occurs during readingprivate int read()
private int peek(int offset)
public int length()