java combine to byte 5b 5d

Solutions on MaxInterview for java combine to byte 5b 5d by the best coders in the world

showing results for - "java combine to byte 5b 5d"
Felix
07 Sep 2017
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()]);
Liza
21 Jan 2020
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}
Mariah
15 Nov 2017
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}
Tomas
23 Nov 2018
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);