Here you can find the source of arrayFromArrayWithLength(final byte[] array, final int length)
public static byte[] arrayFromArrayWithLength(final byte[] array, final int length)
//package com.java2s; //License from project: Apache License public class Main { public static byte[] arrayFromArrayWithLength(final byte[] array, final int length) { final byte[] output = new byte[length]; for (int j = 0; j < length; j++) { output[j] = array[(j % array.length)]; }/* ww w . j a va 2s . co m*/ return output; } }