Here you can find the source of copy(ByteBuffer src, int startindex, int endindex)
public static ByteBuffer copy(ByteBuffer src, int startindex, int endindex)
//package com.java2s; //License from project: LGPL import java.nio.ByteBuffer; public class Main { public static ByteBuffer copy(ByteBuffer src, int startindex, int endindex) { int size = endindex - startindex; ByteBuffer ret = ByteBuffer.allocate(size); src.position(startindex);/*from w w w. j a v a2 s . c o m*/ for (int i = 0; i < size; i++) { ret.put(src.get()); } return ret; } }