code: public ByteArraySegment subSegment(int offset, int length, boolean readOnly) {
          Exceptions.checkArrayRange(offset, length, this.length, "offset", "length");
          return new ByteArraySegment(this.array, this.startOffset + offset, length, readOnly || this.readOnly);
      }
docs: Returns a new ByteArraySegment that is a sub-segment of this ByteArraySegment. The new ByteArraySegment wraps
  the same underlying byte array that this ByteArraySegment does.
  
  @param offset   The offset within this ByteArraySegment where the new ByteArraySegment starts.
  @param length   The length of the new ByteArraySegment.
  @param readOnly Whether the resulting sub-segment should be read-only.
  Note: if this ByteArraySegment is already read-only, this argument is ignored and the resulting
  segment is read-only
  @return The new ByteArraySegment.
  @throws ArrayIndexOutOfBoundsException If offset or length are invalid.