List of utility methods to do ByteBuffer Get
short | getUnsignedByte(final ByteBuffer pByteBuffer) get Unsigned Byte return (short) (pByteBuffer.get() & 0xFF); |
short | getUnsignedByte(final ByteBuffer pByteBuffer, final int pPosition) get Unsigned Byte return (short) (pByteBuffer.get(pPosition) & (short) 0xFF); |
long | getUnsignedInt(final ByteBuffer pByteBuffer) get Unsigned Int return pByteBuffer.getInt() & 0xFFFFFFFFL;
|
long | getUnsignedInt(final ByteBuffer pByteBuffer, final int pPosition) get Unsigned Int return pByteBuffer.getInt(pPosition) & 0xFFFFFFFFL;
|
String | extractNullTerminatedString(ByteBuffer bb) extract Null Terminated String int start = bb.position(); byte[] buffer = new byte[bb.remaining()]; bb.get(buffer); String s = new String(buffer); int nullPos = s.indexOf(0); s = s.substring(0, nullPos); bb.position(start + s.length() + 1); return s; ... |
ByteBuffer | allocateMore(ByteBuffer output) allocate More if (output.capacity() == 0) { return ByteBuffer.allocate(1); ByteBuffer result = ByteBuffer.allocate(output.capacity() * 2); output.flip(); result.put(output); return result; |
ByteBuffer | removeFirstBytes(ByteBuffer buffer, int num) remove First Bytes buffer.position(buffer.limit() - num); byte[] tmp = new byte[buffer.remaining()]; buffer.get(tmp); ByteBuffer res = ByteBuffer.wrap(tmp); res.rewind(); return res; |
short[] | shorts(ByteBuffer buffer) shorts ShortBuffer samples = buffer.asShortBuffer(); short[] shorts = new short[samples.limit()]; for (int i = 0; i < samples.limit(); i++) shorts[i] = samples.get(i); return shorts; |
Object | getObject(ByteBuffer byteBuffer) get Object InputStream input = new ByteArrayInputStream(byteBuffer.array()); ObjectInputStream oi = new ObjectInputStream(input); Object obj = oi.readObject(); input.close(); oi.close(); byteBuffer.clear(); return obj; |
void | skip(ByteBuffer buffer, int length) Increment position in buffer. buffer.position(buffer.position() + length); |