I have a string array of form:
String[] s = {0x22, 0xD2, 0x01}
Now I have to convert it to byte array form like:
byte[] bytes = {(byte)0x22, (byte)0xD2, (byte)0x01}
It can be done in single line in c# but how to do it in Java as I have to append bytes
array to another array of same kind and format.
Here I have included some part of the code as I can't include whole code:
String sr = "22D201";
String[] s = {sr.substring(0, 2),sr.substring(2, 4),sr.substring(4)};
byte[] ret = new byte[]{(byte)0x2C, (byte)0x04, (byte)0x01, (byte)0x67, (byte)0x00, (byte)0x00, (byte)0x3D};
Now I have to append byte[] bytes
to byte[] ret
but I can't as array is in the form of String that is String[] s
. So how to covert String[] s
so that I can add it to byte[] ret
.