Here you can find the source of cloneBuffer(ByteBuffer pesBuffer)
public static ByteBuffer cloneBuffer(ByteBuffer pesBuffer)
//package com.java2s; /**/* ww w . ja v a 2s .c om*/ * This class is part of JCodec ( www.jcodec.org ) This software is distributed * under FreeBSD License * * @author The JCodec project * */ import java.nio.ByteBuffer; public class Main { public static ByteBuffer cloneBuffer(ByteBuffer pesBuffer) { ByteBuffer res = ByteBuffer.allocate(pesBuffer.remaining()); res.put(pesBuffer.duplicate()); res.clear(); return res; } public static ByteBuffer duplicate(ByteBuffer bb) { ByteBuffer out = ByteBuffer.allocate(bb.remaining()); out.put(bb.duplicate()); out.flip(); return out; } }