I have 2 byte array like this:
byte a[i]=1;
byte b[i]=0;
I want to merge it so that the output result becomes "10". I try to use arraycopy and make new output
byte[] output=a.length+b.length;
but it still doesn't work like my expectation. Anybody knows how to solve it?
Try this.
byte[] first = getFirstBytes();
byte[] second = getSecondBytes();
List<Byte> listOfBytes = new ArrayList<Byte>(Arrays.<Byte>asList(first));
listOfBytes.addAll(Arrays.<Byte>asList(second));
byte[] combinedByte = listOfBytes.toArray(new byte[listOfBytes.size()]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With