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

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

Description

Concatenates the given arrays in order of their occurence

License

Apache License

Parameter

Parameter Description
arrays a parameter

Declaration

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

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/* w ww . j  a v  a2  s.c o m*/
     * Concatenates the given arrays in order of their occurence
     * @param arrays
     * @return
     */
    public static byte[] concatArrays(byte[]... arrays) {
        int size = 0;
        for (byte[] cur : arrays) {
            if (cur == null)
                continue;
            size = size + cur.length;
        }

        byte[] out = new byte[size];

        int curPos = 0;
        for (byte[] cur : arrays) {
            if (cur == null)
                continue;
            System.arraycopy(cur, 0, out, curPos, cur.length);
            curPos = curPos + cur.length;
        }

        return out;
    }
}

Related

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