Here you can find the source of readBuf(ByteBuffer buffer)
public static ByteBuffer readBuf(ByteBuffer buffer)
//package com.java2s; /**/*from ww w .j a v a 2 s . c o m*/ * 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 readBuf(ByteBuffer buffer) { ByteBuffer result = buffer.duplicate(); buffer.position(buffer.limit()); return result; } public static ByteBuffer duplicate(ByteBuffer bb) { ByteBuffer out = ByteBuffer.allocate(bb.remaining()); out.put(bb.duplicate()); out.flip(); return out; } }