code: public ByteBuffer compact () {
        // System.arraycopy(backingArray, position + offset, backingArray, offset,
        // remaining());
  
        int rem = remaining();
        for (int i = 0; i < rem; i++) {
          byteArray.set(i, byteArray.get(position + i));
        }
  
        position = limit - position;
        limit = capacity;
        mark = UNSET_MARK;
        return this;
      }
docs: Compacts this byte buffer.
  <p> The remaining bytes will be moved to the head of the buffer, starting from position
  zero. Then the position is set to {@code remaining()}; the limit is set to capacity; the
  mark is cleared. </p>
  
  @return this buffer.
  @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer.