List of utility methods to do ByteBuffer Copy
ByteBuffer | deepCopyVisible(ByteBuffer orig) deep Copy Visible int pos = orig.position(); try { ByteBuffer toReturn; if (orig.isDirect()) { toReturn = ByteBuffer.allocateDirect(orig.remaining()); } else { toReturn = ByteBuffer.allocate(orig.remaining()); toReturn.put(orig); toReturn.order(orig.order()); return (ByteBuffer) toReturn.position(0); } finally { orig.position(pos); |
ByteBuffer | duplicate(ByteBuffer bb) duplicate ByteBuffer out = ByteBuffer.allocate(bb.remaining());
out.put(bb.duplicate());
out.flip();
return out;
|
ByteBuffer | duplicate(ByteBuffer buffer) Duplicate a byte buffer for storing for future use. ByteBuffer newBuffer = ByteBuffer.allocate(buffer.remaining() * 2);
newBuffer.put(buffer);
newBuffer.flip();
return newBuffer;
|
ByteBuffer[] | duplicate(ByteBuffer[] buffers) duplicates the byte buffer array if (buffers == null) { return null; ByteBuffer[] copy = new ByteBuffer[buffers.length]; for (int i = 0; i < copy.length; i++) { copy[i] = duplicate(buffers[i]); return copy; ... |
ByteBuffer[] | duplicate(ByteBuffer[] byteBuffers) duplicate ByteBuffer[] newByteBuffers = new ByteBuffer[byteBuffers.length]; for (int i = 0; i < byteBuffers.length; i++) { newByteBuffers[i] = byteBuffers[i].duplicate(); return newByteBuffers; |
void | memcpy(ByteBuffer dstBuffer, int dstByteOffset, ByteBuffer srcBuffer, int srcByteOffset, int length) memcpy ByteBuffer dstDup = dstBuffer.duplicate(); dstDup.position(dstByteOffset); dstDup.limit(dstByteOffset + length); ByteBuffer srcDup = srcBuffer.duplicate(); srcDup.position(srcByteOffset); srcDup.limit(srcByteOffset + length); dstDup.put(srcDup); |