Here you can find the source of cloneByteBufferList(List
public static List<ByteBuffer> cloneByteBufferList(List<ByteBuffer> source)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; public class Main { public static List<ByteBuffer> cloneByteBufferList(List<ByteBuffer> source) { List<ByteBuffer> ret = new ArrayList<ByteBuffer>(source.size()); for (int k = 0; k < source.size(); k++) { ret.add(cloneByteBuffer(source.get(k))); }//from w w w. j ava 2 s . c om return ret; } public static ByteBuffer cloneByteBuffer(ByteBuffer buf) { ByteBuffer ret = ByteBuffer.allocate(buf.limit() - buf.position()); ret.put(buf); ret.flip(); buf.flip(); return ret; } }