public class DataInput extends Object
Constructor and Description |
---|
DataInput(byte[] buffer)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
getPosition()
Returns the current position.
|
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() |
int |
peekUnsignedByte(int offset)
Peeks one single unsigned byte from the buffer.
|
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 String getString() throws IOException
IOException
- if an error occurs during readingpublic byte readByte() throws IOException
IOException
- if an error occurs during readingpublic int readUnsignedByte() throws IOException
IOException
- if an error occurs during readingpublic int peekUnsignedByte(int offset) throws IOException
IOException
- if an error occurs during readingpublic short readShort() throws IOException
IOException
- if an error occurs during readingpublic int readUnsignedShort() throws IOException
IOException
- if an error occurs during readingpublic int readInt() throws IOException
IOException
- if an error occurs during readingpublic byte[] readBytes(int length) throws IOException
length
- the number of bytes to be readIOException
- if an error occurs during readingpublic int length()
Copyright © 2002–2018 The Apache Software Foundation. All rights reserved.