Java Array Add addArrayElements(byte[] toArray, byte[] fromArray)

Here you can find the source of addArrayElements(byte[] toArray, byte[] fromArray)

Description

adds the elements of the fromArray to the toArray.

License

Open Source License

Declaration

public static byte[] addArrayElements(byte[] toArray, byte[] fromArray) 

Method Source Code

//package com.java2s;
/**********************************************************************************
 Copyright (C) 2009// ww w. j ava  2 s.  c  o  m
 by 52 North Initiative for Geospatial Open Source Software GmbH
    
 Contact: Andreas Wytzisk 
 52 North Initiative for Geospatial Open Source Software GmbH
 Martin-Luther-King-Weg 24
 48155 Muenster, Germany
 info@52north.org
    
 This program is free software; you can redistribute and/or modify it under the
 terms of the GNU General Public License version 2 as published by the Free
 Software Foundation.
    
 This program is distributed WITHOUT ANY WARRANTY; even without the implied
 WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 General Public License for more details.
    
 You should have received a copy of the GNU General Public License along with this 
 program (see gnu-gplv2.txt). If not, write to the Free Software Foundation, Inc., 
 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA or visit the Free Software
 Foundation web page, http://www.fsf.org.
     
 Created on: 19.07.2007
 *********************************************************************************/

public class Main {
    /**
     * adds the elements of the fromArray to the toArray.
     */
    public static byte[] addArrayElements(byte[] toArray, byte[] fromArray) {

        byte[] newToArray = new byte[toArray.length + fromArray.length];

        System.arraycopy(toArray, 0, newToArray, 0, toArray.length);

        System.arraycopy(fromArray, 0, newToArray, toArray.length, fromArray.length);

        return newToArray;
    }

    /**
     * adds the elements of the fromArray to the toArray.
     */
    public static String[] addArrayElements(String[] toArray, String[] fromArray) {

        String[] newToArray = new String[toArray.length + fromArray.length];

        System.arraycopy(toArray, 0, newToArray, 0, toArray.length);

        System.arraycopy(fromArray, 0, newToArray, toArray.length, fromArray.length);

        return newToArray;
    }
}

Related

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