/**
* @author lautturi.com
* Java example: combine two byte arrays in java
*/
import java.util.*;
public class Lautturi {
public static void main(String[] args) {
Byte[] bytes1 = {104, 101, 108, 108, 111, 32};
Byte[] bytes2 = {108, 97, 117, 116, 116, 117, 114, 105, 32, 106, 97, 118, 97, 33};
List<Byte> list = new ArrayList<Byte>(Arrays.asList(bytes1));
list.addAll(Arrays.<Byte>asList(bytes2));
Byte[] combined = list.toArray(new Byte[list.size()]);
System.out.println(Arrays.toString(combined));
}
}
output:
[104, 101, 108, 108, 111, 32, 108, 97, 117, 116, 116, 117, 114, 105, 32, 106, 97, 118, 97, 33]