public class Buffer extends Object
Constructor and Description |
---|
Buffer(byte[] buf) |
Buffer(byte[] buf,
int limit) |
Modifier and Type | Method and Description |
---|---|
void |
appendPacket(Buffer otherBuffer)
Add stream to bytebuffer.
|
byte |
getByteAt(int position) |
long |
getLengthEncodedBinary()
Get next binary data length.
|
byte[] |
getLengthEncodedBytes()
Get next data bytes with unknown length.
|
byte[] |
getLengthEncodedBytesWithLength(long length)
Get next data bytes with known length.
|
long |
getSilentLengthEncodedBinary()
Return next binary field length without moving cursor position.
|
int |
read24bitword()
Read 24 bit integer.
|
byte |
readByte()
Reads a byte from the buffer.
|
int |
readInt()
Read a int (4 bytes) from the buffer.
|
long |
readLong()
Read a long (8 bytes) from the buffer.
|
byte[] |
readRawBytes(int numberOfBytes)
Read raw data.
|
short |
readShort()
Read a short (2 bytes) from the buffer.
|
String |
readString(Charset charset)
Reads a string from the buffer, looks for a 0 to end the string.
|
int |
remaining() |
void |
skipByte() |
void |
skipBytes(int bytesToSkip) |
void |
skipLengthEncodedBytes()
Skip next length encode binary data.
|
public int remaining()
public String readString(Charset charset)
charset
- the charset to use, for example ASCIIpublic short readShort()
public int read24bitword()
public int readInt()
public long readLong()
public byte readByte()
public byte[] readRawBytes(int numberOfBytes)
numberOfBytes
- raw data length.public void skipByte()
public void skipBytes(int bytesToSkip)
public void skipLengthEncodedBytes()
public long getLengthEncodedBinary()
public byte[] getLengthEncodedBytes() throws IOException
IOException
- if connection problem occurpublic byte[] getLengthEncodedBytesWithLength(long length)
length
- binary data lengthpublic byte getByteAt(int position)
public void appendPacket(Buffer otherBuffer)
otherBuffer
- stream to add if neededpublic long getSilentLengthEncodedBinary()
Copyright © 2016. All rights reserved.