| Class | Description |
|---|---|
| ByteBufferUtil |
Utility methods to make ByteBuffers less painful
The following should illustrate the different ways byte buffers can be used
public void testArrayOffet()
{
byte[] b = "test_slice_array".getBytes();
ByteBuffer bb = ByteBuffer.allocate(1024);
assert bb.position() == 0;
assert bb.limit() == 1024;
assert bb.capacity() == 1024;
bb.put(b);
assert bb.position() == b.length;
assert bb.remaining() == bb.limit() - bb.position();
ByteBuffer bb2 = bb.slice();
assert bb2.position() == 0;
//slice should begin at other buffers current position
assert bb2.arrayOffset() == bb.position();
//to match the position in the underlying array one needs to
//track arrayOffset
assert bb2.limit()+bb2.arrayOffset() == bb.limit();
assert bb2.remaining() == bb.remaining();
}
}
|
| Hex | |
| UUIDGen |
The goods are here: www.ietf.org/rfc/rfc4122.txt.
|
Copyright © 2015 The Apache Software Foundation