Copies a specified amount of bytes from the list of buffered data chunks. This function is designed to be inlinable, so please take care when making changes to the function body.
354913
function copyFromBuffer(n, list) {
	  var ret = Buffer.allocUnsafe(n);
	  var p = list.head;
	  var c = 1;
	  p.data.copy(ret);
	  n -= p.data.length;
	  while (p = p.next) {
	    var buf = p.data;
	    var nb = n > buf.length ? buf.length : n;
	    buf.copy(ret, ret.length - n, 0, nb);
	    n -= nb;
	    if (n === 0) {
	      if (nb === buf.length) {
	        ++c;
	        if (p.next) list.head = p.next;else list.head = list.tail = null;
	      } else {
	        list.head = p;
	        p.data = buf.slice(nb);
	      }
	      break;
	    }
	    ++c;
	  }
	  list.length -= c;
	  return ret;
	}
224764
public static int copyWsByteBuffer(WsByteBuffer src, WsByteBuffer dst, int amount)
   {
      int amountCopied = amount;
      int dstRemaining = dst.remaining();
      int srcRemaining = src.remaining();

      if (amountCopied > dstRemaining) amountCopied = dstRemaining;
      if (amountCopied > srcRemaining) amountCopied = srcRemaining;

      if (amountCopied > 0)
      {
         int srcLimit = src.limit();
         src.limit(src.position()+amountCopied);
         dst.put(src);
         src.limit(srcLimit);
      }

      return amountCopied;
   }
316386
private void copy(final WritableByteChannel target,
        final byte[] boundary, final ReadableByteChannel body)
        throws IOException {
        int match = 0;
        boolean cont = true;
        while (cont) {
            if (!this.buffer.hasRemaining()) {
                this.buffer.clear();
                for (int idx = 0; idx < match; ++idx) {
                    this.buffer.put(boundary[idx]);
                }
                match = 0;
                if (body.read(this.buffer) == -1) {
                    break;
                }
                this.buffer.flip();
            }
            final ByteBuffer btarget = this.buffer.slice();
            final int offset = this.buffer.position();
            btarget.limit(0);
            while (this.buffer.hasRemaining()) {
                final byte data = this.buffer.get();
                if (data == boundary[match]) {
                    ++match;
                } else if (data == boundary[0]) {
                    match = 1;
                } else {
                    match = 0;
                    btarget.limit(this.buffer.position() - offset);
                }
                if (match == boundary.length) {
                    cont = false;
                    break;
                }
            }
            target.write(btarget);
        }
    }
968441
public static void copy(Readable from, Appendable to) throws IOException {
     CharBuffer buf = CharBuffer.allocate(2048);
     for (;;) {
       int r = from.read(buf);
       if (r == -1) break;
       buf.flip();
       to.append(buf, 0, r);
     }
  }
893600
@Override
    public void copy(long n, DataBuffer x, int offsetX, int incrX, DataBuffer y, int offsetY, int incrY) {


        if (supportsDataBufferL1Ops()) {
            if (x.dataType() == DataType.DOUBLE) {
                dcopy(n, x, offsetX, incrX, y, offsetY, incrY);
            } else {
                scopy(n, x, offsetX, incrX, y, offsetY, incrY);
            }
        } else {
            long[] shapex = {1, n};
            long[] shapey = {1, n};
            long[] stridex = {incrX, incrX};
            long[] stridey = {incrY, incrY};
            INDArray arrX = Nd4j.create(x, shapex, stridex, offsetX, 'c');
            INDArray arrY = Nd4j.create(x, shapey, stridey, offsetY, 'c');
            copy(arrX, arrY);
        }
    }
915986
private static void copyStream(InputStream is, OutputStream os, int bufferSize)
            throws IOException {
        Assert.checkNotNullParam("is", is);
        Assert.checkNotNullParam("os", os);
        byte[] buff = new byte[bufferSize];
        int rc;
        while ((rc = is.read(buff)) != -1) os.write(buff, 0, rc);
        os.flush();
    }
802687
private void copy(final InputStream in, final SeekableByteChannel out) throws IOException {
        assert in != null : "InStream must be specified";
        assert out != null : "Channel must be specified";

        final byte[] backingBuffer = new byte[1024 * 4];
        final ByteBuffer byteBuffer = ByteBuffer.wrap(backingBuffer);
        int bytesRead = 0;
        while ((bytesRead = in.read(backingBuffer, 0, backingBuffer.length)) > -1) {
            // Limit to the amount we've actually read in, so we don't overflow into old data blocks
            byteBuffer.limit(bytesRead);
            out.write(byteBuffer);
            // Position back to 0
            byteBuffer.clear();
        }
    }
798322
public Buffer copyTo(Buffer out, long offset, long byteCount) {
    if (out == null) throw new IllegalArgumentException("out == null");
    checkOffsetAndCount(size, offset, byteCount);
    if (byteCount == 0) return this;

    out.size += byteCount;

    // Skip segments that we aren't copying from.
    Segment s = head;
    for (; offset >= (s.limit - s.pos); s = s.next) {
      offset -= (s.limit - s.pos);
    }

    // Copy one segment at a time.
    for (; byteCount > 0; s = s.next) {
      Segment copy = new Segment(s);
      copy.pos += offset;
      copy.limit = Math.min(copy.pos + (int) byteCount, copy.limit);
      if (out.head == null) {
        out.head = copy.next = copy.prev = copy;
      } else {
        out.head.prev.push(copy);
      }
      byteCount -= copy.limit - copy.pos;
      offset = 0;
    }

    return this;
  }
1037247
public static void copy(HttpServletRequest req, OutputStream output) throws IOException {
        InputStream input = req.getInputStream();
        int availableBytes = req.getContentLength();
        log.debug("copy - available: {}", availableBytes);
        if (availableBytes > 0) {
            byte[] buf = new byte[availableBytes];
            int bytesRead = input.read(buf);
            while (bytesRead != -1) {
                output.write(buf, 0, bytesRead);
                bytesRead = input.read(buf);
                log.trace("Bytes read: {}", bytesRead);
            }
            output.flush();
        } else {
            log.debug("Nothing to available to copy");
        }
    }
712402
public static int copy(InputStream in, OutputStream out) throws IOException {
        assert in != null : "No input stream specified";
        assert out != null : "No output stream specified";
        try {
            int byteCount = 0;
            byte[] buffer = new byte[BUFFER_SIZE];
            int bytesRead = -1;
            while ((bytesRead = in.read(buffer)) != -1) {
                out.write(buffer, 0, bytesRead);
                byteCount += bytesRead;
            }
            out.flush();
            return byteCount;
        } finally {
            try {
                in.close();
            } catch (IOException ex) {
            }
            try {
                out.close();
            } catch (IOException ex) {
            }
        }
    }
1027283
public static void copy(InputStream input, OutputStream output) throws IOException {
		byte[] buf = new byte[BUFFER_SIZE];
		int num = 0;

		while ((num = input.read(buf, 0, buf.length)) != -1) {
			output.write(buf, 0, num);
		}
	}
1355409
public void writeBytes (Object from, long offset, int count) throws KryoException {
		int copyCount = Math.min(capacity - position, count);
		while (true) {
			unsafe.copyMemory(from, offset, buffer, byteArrayBaseOffset + position, copyCount);
			position += copyCount;
			count -= copyCount;
			if (count == 0) break;
			offset += copyCount;
			copyCount = Math.min(capacity, count);
			require(copyCount);
		}
	}
1292139
private static ByteBuffer copyAll(List<ByteBuffer> buffers) {
    int size = 0;
    for (ByteBuffer b : buffers) {
      size += b.remaining();
    }
    ByteBuffer result = allocate(size);
    for (ByteBuffer b : buffers) {
      result.put(b);
    }
    result.flip();
    return result;
  }
27338
public static List<ByteBuffer> cloneByteBufferList(List<ByteBuffer> source) {
    List<ByteBuffer> ret = new ArrayList<>(source.size());
    for (ByteBuffer b : source) {
      ret.add(cloneByteBuffer(b));
    }
    return ret;
  }
831405
function copyBuffer(buf) {
  var targetBuffer = new Buffer(buf.length);
  buf.copy(targetBuffer);
  return targetBuffer;
}
1109135
public void copyTo(int srcOffs, byte[] dst, int offs, int len) {
        arraycopy(bytes, srcOffs, dst, offs, len);
    }
622522
public static long copy(InputStream in, OutputStream out, int bufferSize, StreamProgress streamProgress) throws IORuntimeException {
		Assert.notNull(in, "InputStream is null !");
		Assert.notNull(out, "OutputStream is null !");
		if (bufferSize <= 0) {
			bufferSize = DEFAULT_BUFFER_SIZE;
		}

		byte[] buffer = new byte[bufferSize];
		if (null != streamProgress) {
			streamProgress.start();
		}
		long size = 0;
		try {
			for (int readSize = -1; (readSize = in.read(buffer)) != EOF;) {
				out.write(buffer, 0, readSize);
				size += readSize;
				out.flush();
				if (null != streamProgress) {
					streamProgress.progress(size);
				}
			}
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
		if (null != streamProgress) {
			streamProgress.finish();
		}
		return size;
	}