Java tutorial
//package com.java2s; public class Main { /** * Return a clone of the given byte array (performs null check beforehand). * * @param array the array to clone * @return the clone of the given array, or <tt>null</tt> if the array is * <tt>null</tt> */ public static byte[] clone(byte[] array) { if (array == null) { return null; } byte[] result = new byte[array.length]; System.arraycopy(array, 0, result, 0, array.length); return result; } }