public static byte[] copyOf(byte[] src, int length) {
        byte[] dest = new byte[length];
        System.arraycopy(src, 0, dest, 0, Math.min(src.length, length));
        return dest;
    }
@Test
    public void copyOf() {
        byte[] bs = new byte[] { 1, 2, 3, 5 };
        byte[] cp = CodecUtils.copyOf(bs, 3);
        Assert.assertArrayEquals(cp, new byte[] { 1, 2, 3 });

        cp = CodecUtils.copyOf(bs, 5);
        Assert.assertArrayEquals(cp, new byte[] { 1, 2, 3, 5, 0 });
    }