Java ByteBuffer Clone cloneBuffer(ByteBuffer pesBuffer)

Here you can find the source of cloneBuffer(ByteBuffer pesBuffer)

Description

clone Buffer

License

BSD License

Declaration

public static ByteBuffer cloneBuffer(ByteBuffer pesBuffer) 

Method Source Code

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

Related

  1. clone(ByteBuffer original)
  2. clone(final ByteBuffer buf)
  3. clone(final ByteBuffer original)
  4. cloneAsDirectByteBuffer(byte[] input, int offset, int len)
  5. cloneBufferData(ByteBuffer srcBuffer)
  6. cloneByteBuffer(ByteBuffer buf)
  7. cloneByteBuffer(ByteBuffer buf)
  8. cloneByteBufferList(List source)