List of utility methods to do ByteBuffer Read
Serializable | readObject(ByteBuffer byteBuffer) read Object ByteArrayInputStream bis = null; ObjectInputStream ois = null; Serializable object = null; try { byte[] bytes = readToBytes(byteBuffer); bis = new ByteArrayInputStream(bytes); ois = new ObjectInputStream(new BufferedInputStream(bis)); object = (Serializable) ois.readObject(); ... |
double | readReal(ByteBuffer bb) read Real return bb.getDouble();
|
int | readResBit15(ByteBuffer fromBuffer) read Res Bit int b = readUnsignedByte(fromBuffer); if ((b & 0x80) != 0) { return (short) (((b & 0x7F) << 8) + readUnsignedByte(fromBuffer)); return (short) b; |
int | readShortLE(ByteBuffer buf, int i) read Short LE return (buf.get(i) & 0xFF) | ((buf.get(i + 1) & 0xFF) << 8);
|
int | readShortLength(ByteBuffer bb) read Short Length int length = (bb.get() & 0xFF) << 8; return length | (bb.get() & 0xFF); |
short[] | readShorts(final ByteBuffer bb, final int length) read Shorts final short[] result = new short[length]; for (int index = 0; index < length; index++) { result[index] = bb.getShort(); return result; |
String | readShortString(ByteBuffer buffer) read bytes with a short sign prefix(mark the size of bytes) short size = buffer.getShort(); if (size < 0) { return null; byte[] bytes = new byte[size]; buffer.get(bytes); return fromBytes(bytes); |
int | readSignedVarint(ByteBuffer buffer) Read a signed integer. final int raw = readUnsignedVarint(buffer); return (raw >>> 1) ^ -(raw & 1); |
int | readSize(ByteBuffer buf) Read size from ByteBuffer int s = 0; for (int count = 0; count < 4; count++) { byte b = (byte) (buf.get() & 0xff); s <<= 7; s |= b & 0x7f; if (0 == (b & 0x80)) { break; return s; |
int | readSize(ByteBuffer buffer) read Size final byte b = buffer.get(); if (b == -1) return -1; else if (b == -2) { final int s = buffer.getInt(); if (s < 0) throw new RuntimeException("negative array size"); return s; ... |