Java tutorial
//package com.java2s; public class Main { public static byte[] insertBytes(byte[] target, int offset, int targetLength, byte[] insertion, int insertionLength) { byte result[] = new byte[(targetLength + insertionLength)]; System.arraycopy(target, 0, result, 0, offset); System.arraycopy(insertion, 0, result, offset, insertionLength); System.arraycopy(target, offset, result, (insertionLength + offset), (targetLength - offset)); return result; } }