public class DataInputBuffer
extends java.io.DataInputStream
DataInput
implementation that reads from an in-memory
buffer.
This saves memory over creating a new DataInputStream and ByteArrayInputStream each time data is read.
Typical usage is something like the following:
DataInputBuffer buffer = new DataInputBuffer(); while (... loop condition ...) { byte[] data = ... get data ...; int dataLength = ... get data length ...; buffer.reset(data, dataLength); ... read buffer using DataInput methods ... }
Constructor and Description |
---|
DataInputBuffer()
Constructs a new empty buffer.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
getData() |
int |
getLength()
Returns the length of the input.
|
int |
getPosition()
Returns the current position in the input.
|
void |
reset(byte[] input,
int length)
Resets the data that the buffer reads.
|
void |
reset(byte[] input,
int start,
int length)
Resets the data that the buffer reads.
|
read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, readUTF, skipBytes
public void reset(byte[] input, int length)
public void reset(byte[] input, int start, int length)
public byte[] getData()
public int getPosition()
public int getLength()