Tutorial by Examples

There's two ways to create a ByteBuffer, where one can be subdivided again. If you have an already existing byte[], you can "wrap" it into a ByteBuffer to simplify processing: byte[] reqBuffer = new byte[BUFFER_SIZE]; int readBytes = socketInputStream.read(reqBuffer); final ByteBuffer ...
Given a ByteBuffer instance one can write primitive-type data to it using relative and absolute put. The striking difference is that putting data using the relative method keeps track of the index the data is inserted at for you, while the absolute method always requires giving an index to put the d...
DirectByteBuffer is special implementation of ByteBuffer that has no byte[] laying underneath. We can allocate such ByteBuffer by calling: ByteBuffer directBuffer = ByteBuffer.allocateDirect(16); This operation will allocate 16 bytes of memory. The contents of direct buffers may reside outside ...

Page 1 of 1