Java examples for java.nio:ByteBuffer Copy
copy ByteBuffer
//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 2 s . co m 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; } }