Java Array Add addArrayAll(byte[] array1, byte[] array2)

Here you can find the source of addArrayAll(byte[] array1, byte[] array2)

Description

add Array All

License

Apache License

Declaration

public static byte[] addArrayAll(byte[] array1, byte[] array2) 

Method Source Code

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

public class Main {
    public static byte[] addArrayAll(byte[] array1, byte[] array2) {
        if (array1 == null)
            return clone(array2);
        if (array2 == null) {
            return clone(array1);
        }//from  w  w w  .  java  2 s.  c o  m
        byte[] joinedArray = new byte[array1.length + array2.length];
        System.arraycopy(array1, 0, joinedArray, 0, array1.length);
        System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);
        return joinedArray;
    }

    private static byte[] clone(byte[] array) {
        if (array == null) {
            return null;
        }
        return (byte[]) array.clone();
    }
}

Related

  1. addArray(int[] a, int p)
  2. addArray(int[] a, int[] b)
  3. addArray(Object[] Old, Object[] New)
  4. addArray(Object[][] first, Object[][]... more)
  5. addArray(StringBuffer RCode, String name, T[] array, boolean useEquals, boolean isString)
  6. addArrayElements(byte[] toArray, byte[] fromArray)
  7. addArrays(final int[] a, final int[] b)
  8. addArrays(float[] arr1, float[] arr2, float[] arr3)
  9. addArrays(Object[] array1, Object[] array2)