code: public Buffer writeTo(OutputStream out, long byteCount) throws IOException {
      if (out == null) throw new IllegalArgumentException("out == null");
      checkOffsetAndCount(size, 0, byteCount);
  
      Segment s = head;
      while (byteCount > 0) {
        int toCopy = (int) Math.min(byteCount, s.limit - s.pos);
        out.write(s.data, s.pos, toCopy);
  
        s.pos += toCopy;
        size -= toCopy;
        byteCount -= toCopy;
  
        if (s.pos == s.limit) {
          Segment toRecycle = s;
          head = s = toRecycle.pop();
          SegmentPool.recycle(toRecycle);
        }
      }
  
      return this;
    }
docs: Write {@code byteCount} bytes from this to {@code out}.