Android Byte Array Concatenate concatByteArray(byte[] a, byte[] b)

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

Description

Method Concatenates the specified byte[].

Parameter

Parameter Description
number The int value to be converted.

Declaration

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

Method Source Code

//package com.java2s;

public class Main {
    /**/*  ww  w .  j  a v  a  2  s .  c  o m*/
     *
     * Method Concatenates the specified byte[].
     *
     * @param number The int value to be converted.
     *
     */
    public static byte[] concatByteArray(byte[] a, byte[] b) {
        int aL = a.length;
        int bL = b.length;
        int len = aL + bL;
        byte[] c = new byte[len];

        System.arraycopy(a, 0, c, 0, aL);
        System.arraycopy(b, 0, c, aL, bL);

        return c;
    }

    public static void arraycopy(String src, int srcOffset, byte[] dst,
            int dstOffset, int length) {
        if (src == null || dst == null) {
            throw new NullPointerException("invalid byte array ");
        }
        if ((src.length() < (srcOffset + length))
                || (dst.length < (dstOffset + length))) {
            throw new IndexOutOfBoundsException("invalid length: " + length);
        }
        for (int i = 0; i < length; i++) {
            dst[dstOffset + i] = (byte) src.charAt(srcOffset + i);
        }
    }
}

Related

  1. concat(byte[] a, byte[] b)
  2. concat(byte[] base, byte... extension)
  3. concat(int[] base, int... extension)
  4. copyBytesIntoByteArray(byte[] dest, byte[] src)
  5. copyBytesIntoByteArrayAtOffset(byte[] dest, byte[] src, int offset)
  6. copyBytesIntoByteArrayUpToLength(byte[] dest, byte[] src, int offset)