How to concatinate byte array in java

What is the simple method two concatenate two byte arrays in Java ?
i use this function but CREATE an error…java.lang.ArrayIndexOutOfBoundsException: 16
MY FUNCTION IS

public static byte[] concatinate(byte[] a, byte[] b) {
byte[] c = new byte[100];
for (int i = 0; i < (a.length + b.length); i++) {
if (i < a.length) {
 c[i] = a[i];
 } else {
 c[i] = b[i];
 }
 }
return c;
}


Source: java

Leave a Reply