Java Array Merge mergeByteArrays(byte[] array1, byte[] array2)

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

Description

Merges two byte arrays

License

Open Source License

Parameter

Parameter Description
array1 a parameter
array2 a parameter

Return

the new merged array

Declaration

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

Method Source Code

//package com.java2s;

public class Main {
    /**/*from w w  w.jav  a  2 s  . c  om*/
     * Merges two byte arrays
     * @param array1
     * @param array2
     * @return the new merged array
     */
    public static byte[] mergeByteArrays(byte[] array1, byte[] array2) {
        byte[] combined = new byte[array1.length + array2.length];
        for (int i = 0; i < combined.length; ++i) {
            combined[i] = i < array1.length ? array1[i] : array2[i - array1.length];
        }
        return combined;
    }
}

Related

  1. mergeArrays(T[] lhs, T[] rhs)
  2. MergeArrays(T[]... arrs)
  3. mergeArrayToString(final String[] array)
  4. mergeByArray(int[] a, int[] b)
  5. mergeByteArraies(byte[] array1, byte[] array2)
  6. mergeByteArrays(byte[] one, byte[] two)
  7. mergeBytearrays(byte[] ret, byte[] header, byte[] body)
  8. mergeCharArrays(char[] array1, char[] array2)
  9. mergeColumnsSafely(int[] arrOriginalColumns, int[] arrExtraColumns)