code: public void writeTo(Segment sink, int byteCount) {
      if (!sink.owner) throw new IllegalArgumentException();
      if (sink.limit + byteCount > SIZE) {
        // We can't fit byteCount bytes at the sink's current position. Shift sink first.
        if (sink.shared) throw new IllegalArgumentException();
        if (sink.limit + byteCount - sink.pos > SIZE) throw new IllegalArgumentException();
        System.arraycopy(sink.data, sink.pos, sink.data, 0, sink.limit - sink.pos);
        sink.limit -= sink.pos;
        sink.pos = 0;
      }
  
      System.arraycopy(data, pos, sink.data, sink.limit, byteCount);
      sink.limit += byteCount;
      pos += byteCount;
    }
docs: Moves {@code byteCount} bytes from this segment to {@code sink}.