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

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

Description

Merge byte arraies.

License

Open Source License

Parameter

Parameter Description
array1 the array1
array2 the array2

Return

the byte[]

Declaration

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

Method Source Code

//package com.java2s;
/**************************************************************************
 * Copyright (c) Dawn InfoTek Inc. 1999, 2004, 2008 -All rights reserved. * 
 * (<http://www.dawninfotek.com>)                                         *
 *                                                                        *
 * This file contains proprietary intellectual property of                *
 * Dawn InfoTek Inc. The contents of and information in this file         *
 * is only to be used in conjunction with a valid Dawn4J license          *
 * as specified in the Dawn4J license agreement. All other use            *
 * is prohibited.                                                         *
 **************************************************************************/

public class Main {
    /**//from   ww w .  j av  a  2 s  .  co m
     * Merge byte arraies.
     * 
     * @param array1
     *            the array1
     * @param array2
     *            the array2
     * 
     * @return the byte[]
     */
    public static byte[] mergeByteArraies(byte[] array1, byte[] array2) {

        if (array1 == null) {
            return array2;
        } else if (array2 == null) {
            return array1;
        } else {
            byte[] result = new byte[array1.length + array2.length];
            System.arraycopy(array1, 0, result, 0, array1.length);
            System.arraycopy(array2, 0, result, array1.length, array2.length);

            return result;
        }
    }
}

Related

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