Here you can find the source of writeL(ByteBuffer to, ByteBuffer from, int count)
public static void writeL(ByteBuffer to, ByteBuffer from, int count)
//package com.java2s; /**/*from ww w. jav a 2 s . com*/ * 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 void writeL(ByteBuffer to, ByteBuffer from, int count) { if (from.hasArray()) { to.put(from.array(), from.arrayOffset() + from.position(), Math.min(from.remaining(), count)); } else { to.put(toArrayL(from, count)); } } public static byte[] toArrayL(ByteBuffer buffer, int count) { byte[] result = new byte[Math.min(buffer.remaining(), count)]; buffer.duplicate().get(result); return result; } public static ByteBuffer duplicate(ByteBuffer bb) { ByteBuffer out = ByteBuffer.allocate(bb.remaining()); out.put(bb.duplicate()); out.flip(); return out; } }