Java Array Concatenate concatArray(byte data1[], byte data2[])

Here you can find the source of concatArray(byte data1[], byte data2[])

Description

concat Array

License

Open Source License

Parameter

Parameter Description
data1 a parameter
data2 a parameter

Declaration

public static byte[] concatArray(byte data1[], byte data2[]) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2008, 2014 IBM Corp.//from  w  w  w  .j ava  2s .  c o  m
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Eclipse Distribution License v1.0 which accompany this distribution. 
 *
 * The Eclipse Public License is available at 
 *    http://www.eclipse.org/legal/epl-v10.html
 * and the Eclipse Distribution License is available at 
 *   http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * Contributors:
 *    Ian Craggs - initial API and implementation and/or initial documentation
 *******************************************************************************/

public class Main {
    /**
     * @param data1
     * @param data2
     * @return
     */
    public static byte[] concatArray(byte data1[], byte data2[]) {
        byte temp[] = new byte[data1.length + data2.length];
        System.arraycopy(data1, 0, temp, 0, data1.length);
        System.arraycopy(data2, 0, temp, data1.length, data2.length);
        return (temp);
    }

    /**
     * @param data1
     * @param off1
     * @param len1
     * @param data2
     * @param off2
     * @param len2
     * @return
     */
    public static byte[] concatArray(byte data1[], int off1, int len1, byte data2[], int off2, int len2) {
        byte temp[] = new byte[len1 + len2];
        System.arraycopy(data1, off1, temp, 0, len1);
        System.arraycopy(data2, off2, temp, len1, len2);
        return (temp);
    }
}

Related

  1. concatAll(byte[] first, byte[]... rest)
  2. concatAll(byte[]... args)
  3. concatAll(T[] first, T[]... rest)
  4. concatAll(T[] first, T[]... rest)
  5. concatAllArrays(byte[] data1, byte[]... remaining)
  6. concatArray(byte[] old1, byte[] old2)
  7. concatArray(int[] src, String separator)
  8. concatArray(Object... objects)
  9. concatArray(Object[] arr1, Object newValue)