Android Byte Array Copy getCopyByteArrayArray(byte[] src, int start, int length, int subArrayLength)

Here you can find the source of getCopyByteArrayArray(byte[] src, int start, int length, int subArrayLength)

Description

new byte[] { 8, 4, 2, 1 }, 0, 4, 2 => new byte[][]{{8,4}, {2,1}}

License

Open Source License

Parameter

Parameter Description
src a parameter
start a parameter
length a parameter
subArrayLength a parameter

Declaration


public static byte[][] getCopyByteArrayArray(byte[] src, int start,
        int length, int subArrayLength) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from  www.  ja v  a 2s  .  c o  m*/
     * new byte[] { 8, 4, 2, 1 }, 0, 4, 2 => new byte[][]{{8,4}, {2,1}}
     * 
     * @param src
     * @param start
     * @param length
     * @param subArrayLength
     * @return
     */

    public static byte[][] getCopyByteArrayArray(byte[] src, int start,
            int length, int subArrayLength) {
        byte[][] dest = new byte[length / subArrayLength][subArrayLength];
        byte[] temp = new byte[length];
        System.arraycopy(src, start, temp, 0, length);
        for (int i = 0; i < dest.length; i++) {
            System.arraycopy(temp, i * subArrayLength, dest[i], 0,
                    subArrayLength);
        }

        return dest;
    }
}

Related

  1. copy(byte[] from)
  2. copy(byte[] rSource)
  3. copy(byte[] source, byte[] target)
  4. copyByteArray(byte[] source)
  5. getCopyByteArray(byte[] src, int start, int length)