Android ByteBuffer Copy copyByteBuffer(ByteBuffer paramByteBuffer)

Here you can find the source of copyByteBuffer(ByteBuffer paramByteBuffer)

Description

copy Byte Buffer

Declaration

public static ByteBuffer copyByteBuffer(ByteBuffer paramByteBuffer) 

Method Source Code

//package com.java2s;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public class Main {
    public static ByteBuffer copyByteBuffer(ByteBuffer paramByteBuffer) {
        ByteBuffer localByteBuffer = newByteBuffer(paramByteBuffer
                .remaining());/*from w  w  w.  j  a v  a 2s  .  com*/
        paramByteBuffer.mark();
        localByteBuffer.put(paramByteBuffer);
        paramByteBuffer.reset();
        localByteBuffer.rewind();
        return localByteBuffer;
    }

    public static ByteBuffer newByteBuffer(int paramInt) {
        ByteBuffer localByteBuffer = ByteBuffer.allocateDirect(paramInt);
        localByteBuffer.order(ByteOrder.nativeOrder());
        return localByteBuffer;
    }
}

Related

  1. clone(ByteBuffer original)
  2. copyFromBufferToBuffer(ByteBuffer out, ByteBuffer in, int sourceOffset, int length)