code: public void copyFrom(ByteArraySegment source, int targetOffset, int length) {
          Preconditions.checkState(!this.readOnly, "Cannot modify a read-only ByteArraySegment.");
          Exceptions.checkArrayRange(targetOffset, length, this.length, "index", "values.length");
          Preconditions.checkElementIndex(length, source.getLength() + 1, "length");
  
          System.arraycopy(source.array, source.startOffset, this.array, targetOffset + this.startOffset, length);
      }
docs: Copies a specified number of bytes from the given ByteArraySegment into this ByteArraySegment.
  
  @param source       The ByteArraySegment to copy bytes from.
  @param targetOffset The offset within this ByteArraySegment to start copying at.
  @param length       The number of bytes to copy.
  @throws IllegalStateException          If the ByteArraySegment is readonly.
  @throws ArrayIndexOutOfBoundsException If targetOffset or length are invalid.