Java tutorial
//package com.java2s; // Licensed under the MIT License: import java.nio.ByteBuffer; public class Main { static void memcpy(ByteBuffer dstBuffer, int dstByteOffset, ByteBuffer srcBuffer, int srcByteOffset, int length) { 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); } }