All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.interfax.rest.client.util.ArrayUtil Maven / Gradle / Ivy

There is a newer version: 0.2
Show newest version
package net.interfax.rest.client.util;

public class ArrayUtil {

    public static byte[][] chunkArray(byte[] array, int chunkSize) {
        int numOfChunks = (int)Math.ceil((double)array.length / chunkSize);
        byte[][] output = new byte[numOfChunks][];

        for(int i = 0; i < numOfChunks; ++i) {
            int start = i * chunkSize;
            int length = Math.min(array.length - start, chunkSize);

            byte[] temp = new byte[length];
            System.arraycopy(array, start, temp, 0, length);
            output[i] = temp;
        }

        return output;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy