1byte[] one = getBytesForOne();
2byte[] two = getBytesForTwo();
3
4List<Byte> list = new ArrayList<Byte>(Arrays.<Byte>asList(one));
5list.addAll(Arrays.<Byte>asList(two));
6
7byte[] combined = list.toArray(new byte[list.size()]);
1byte[] one = getBytesForOne();
2byte[] two = getBytesForTwo();
3byte[] combined = new byte[one.length + two.length];
4
5for (int i = 0; i < combined.length; ++i)
6{
7 combined[i] = i < one.length ? one[i] : two[i - one.length];
8}
1public static byte[] addAll(final byte[] array1, byte[] array2) {
2 byte[] joinedArray = Arrays.copyOf(array1, array1.length + array2.length);
3 System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);
4 return joinedArray;
5}
1byte[] one = getBytesForOne();
2byte[] two = getBytesForTwo();
3byte[] combined = new byte[one.length + two.length];
4
5System.arraycopy(one,0,combined,0 ,one.length);
6System.arraycopy(two,0,combined,one.length,two.length);