Tutorial by Examples: bytebuffer

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 ...
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