code: private void moveBufferTo(byte[] dest) {
      int size = endIndex - index;
      System.arraycopy(buffer, index, dest, 0, size);
      index = 0;
      endIndex = size;
    }
docs: Moves bytes from the buffer to the beginning of the destination buffer. Also sets the index and
  endIndex variables.
  
  @param dest The destination buffer.