Java Array Concatenate concatenate(byte[] a, byte[] b)

Here you can find the source of concatenate(byte[] a, byte[] b)

Description

concatenate

License

Open Source License

Declaration

public static byte[] concatenate(byte[] a, byte[] b) 

Method Source Code


//package com.java2s;
/*-------------------------------------------------------------------------------------------------
 - #%L                                                                                            -
 - chvote-protocol-poc                                                                            -
 - %%                                                                                             -
 - Copyright (C) 2016 - 2017 R?publique et Canton de Gen?ve                                       -
 - %%                                                                                             -
 - This program is free software: you can redistribute it and/or modify                           -
 - it under the terms of the GNU Affero General Public License as published by                    -
 - the Free Software Foundation, either version 3 of the License, or                              -
 - (at your option) any later version.                                                            -
 -                                                                                                -
 - This program is distributed in the hope that it will be useful,                                -
 - but WITHOUT ANY WARRANTY; without even 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 Affero General Public License                       -
 - along with this program. If not, see <http://www.gnu.org/licenses/>.                           -
 - #L%                                                                                            -
 -------------------------------------------------------------------------------------------------*/

import java.util.Arrays;

public class Main {
    public static byte[] concatenate(byte[] a, byte[] b) {
        byte[] local_a = Arrays.copyOf(a, a.length);
        byte[] local_b = Arrays.copyOf(b, b.length);
        byte[] concatenated = new byte[local_a.length + local_b.length];
        System.arraycopy(local_a, 0, concatenated, 0, local_a.length);
        System.arraycopy(local_b, 0, concatenated, local_a.length, local_b.length);
        return concatenated;
    }/*from w w  w . j  a  v a2  s.  com*/
}

Related

  1. concatArrays(String[] array, String[] arrayToBeConcat)
  2. concatArrays(T[] first, T[] second)
  3. concatArrays(T[] first, T[] second)
  4. concatByteArrays(final byte[] array1, final byte[] array2)
  5. concatenate(@SuppressWarnings("unchecked") T[]... arrays)
  6. concatenate(double[] p1, double[] p2)
  7. concatenate(float[][] a, float[][] b, int dim)
  8. concatenate(int[]... arrays)
  9. concatenate(Object[] array)