ByteBuffer compact() method in Java with Examples
The compact() method of java.nio.ByteBuffer class is used to compact the given buffer.The bytes between the buffer's current position and its limit, if any, are copied to the beginning of the buffer. That is, the byte at index p = position() is copied to index zero, the byte at index p + 1 is copied