Java Array Merge merge(byte[]... arrays)

Here you can find the source of merge(byte[]... arrays)

Description

merge

License

Open Source License

Parameter

Parameter Description
arrays - arrays to merge

Return

- merged array

Declaration

public static byte[] merge(byte[]... arrays) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from   w w w  .  j  a  va2 s. c  o  m
     * @param arrays - arrays to merge
     * @return - merged array
     */
    public static byte[] merge(byte[]... arrays) {
        int arrCount = 0;
        int count = 0;
        for (byte[] array : arrays) {
            arrCount++;
            count += array.length;
        }

        // Create new array and copy all array contents
        byte[] mergedArray = new byte[count];
        int start = 0;
        for (byte[] array : arrays) {
            System.arraycopy(array, 0, mergedArray, start, array.length);
            start += array.length;
        }
        return mergedArray;
    }
}

Related

  1. merge(byte[] a, byte[] b)
  2. merge(byte[] array1, byte[] array2)
  3. merge(byte[] signature, byte[] message)
  4. merge(byte[] src, byte[] src2, int start, int length)
  5. merge(byte[] src1, byte[] src2)
  6. merge(byte[]... bytes)
  7. merge(double[] a, int[] b, int p, int q, int r)
  8. merge(double[]... args)
  9. merge(E[] a1, E[] a2)