Here you can find the source of copy(ByteBuffer src, int srcStartindex, ByteBuffer dest, int destStartIndex, int length)
Parameter | Description |
---|---|
src | a parameter |
srcStartindex | a parameter |
dest | a parameter |
destStartIndex | a parameter |
length | a parameter |
public static void copy(ByteBuffer src, int srcStartindex, ByteBuffer dest, int destStartIndex, int length)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; public class Main { /**/*from w ww .java 2s .com*/ * * @param src * @param srcStartindex * @param dest * @param destStartIndex * @param length */ public static void copy(ByteBuffer src, int srcStartindex, ByteBuffer dest, int destStartIndex, int length) { System.arraycopy(src.array(), srcStartindex, dest.array(), destStartIndex, length); } public static ByteBuffer copy(ByteBuffer src, int startindex, int endindex) { int size = endindex - startindex; int initPosition = src.position(); int initLimit = src.limit(); src.position(startindex); src.limit(endindex); ByteBuffer ret = ByteBuffer.allocate(size); ret.put(src); ret.flip(); src.position(initPosition); src.limit(initLimit); return ret; } public static ByteBuffer copy(ByteBuffer src) { int startindex = src.position(); int endindex = src.limit(); return copy(src, startindex, endindex); } }