Java Array Concatenate concatArrays(byte[]... arrays)

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

Description

Takes a variable amount of byte arrays as input and returns a merged byte array by concatenating the input in the order of the parameterlist.

License

BSD License

Parameter

Parameter Description
arrays the arrays to concatenate together

Return

a merged byte array

Declaration

public static final byte[] concatArrays(byte[]... arrays) 

Method Source Code

//package com.java2s;
/*/*from   ww  w  . jav  a 2 s . c  o  m*/
 * This file is part of an unofficial ISO20008-2.2 sample implementation to
 * evaluate certain schemes for their applicability on Android-based mobile
 * devices. The source is licensed under the modified 3-clause BSD license,
 * see the readme.
 * 
 * The code was published in conjunction with the publication called 
 * "Group Signatures on Mobile Devices: Practical Experiences" by
 * Potzmader, Winter, Hein, Hanser, Teufl and Chen
 */

public class Main {
    /**
     * Takes a variable amount of byte arrays as input and returns a merged
     * byte array by concatenating the input in the order of the parameterlist.
     * 
     * @param arrays the arrays to concatenate together
     * @return a merged byte array
     */
    public static final byte[] concatArrays(byte[]... arrays) {
        int length = 0;
        for (byte[] arr : arrays)
            length += arr.length;

        byte[] merged = new byte[length];
        int offset = 0;
        for (byte[] arr : arrays) {
            System.arraycopy(arr, 0, merged, offset, arr.length);
            offset += arr.length;
        }

        return merged;
    }
}

Related

  1. concatArray(String[] array, int start, String def)
  2. concatArray(String[] array, String glue)
  3. concatArray(T[] first, T[]... rest)
  4. concatArrays(byte[] a, byte[] b)
  5. concatArrays(byte[]... arrays)
  6. concatArrays(byte[]... byaArrays)
  7. concatArrays(byte[][] arrays)
  8. concatArrays(double[] d1, double[] d2)
  9. concatArrays(final byte[] arr1, final byte[] arr2)