Here you can find the source of copy(ByteBuffer origin, int start, int end)
public static ByteBuffer copy(ByteBuffer origin, int start, int end)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; import java.nio.ByteOrder; public class Main { public static ByteBuffer copy(ByteBuffer origin, int start, int end) { ByteOrder order = origin.order(); ByteBuffer copy = origin.duplicate(); copy.position(start);// w ww . j a va 2 s .co m copy.limit(end); copy = copy.slice(); copy.order(order); return copy; } public static ByteBuffer copy(ByteBuffer origin, int start) { return copy(origin, start, origin.limit()); } }