Java tutorial
//package com.java2s; public class Main { public static byte[] resizeArray(byte[] source, int len) { byte[] target = new byte[len]; len = (source.length < len) ? source.length : len; System.arraycopy(source, 0, target, 0, len); return target; } }