Java ByteBuffer Write writeL(ByteBuffer to, ByteBuffer from, int count)

Here you can find the source of writeL(ByteBuffer to, ByteBuffer from, int count)

Description

write L

License

BSD License

Declaration

public static void writeL(ByteBuffer to, ByteBuffer from, int count) 

Method Source Code

//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;
    }
}

Related

  1. writeInt24(int v, ByteBuffer buffer)
  2. writeInt4(final ByteBuffer bb, int value, int highValue, final boolean flush)
  3. writeInt8(final ByteBuffer bb, int value)
  4. writeIntArray(ByteBuffer buf, int[] arr)
  5. writeInts4(final ByteBuffer bb, final int... values)
  6. writeLen(int len, ByteBuffer dest, int dOff)
  7. writeLength(ByteBuffer buffer, long l)
  8. writeLong(ByteBuffer buf, long value, int len)
  9. writeLong(ByteBuffer logBuf, long l)