I have a 40 chars text String which is written in log files as follows:
0xee, 0x36, 0xe3, 0x57, 0x2b, 0x06, 0x1e, 0x3e, 0x5a, 0x3e, 0xc0, 0x07, 0xab, 0x81, 0xa7, 0x76, 0xa4, 0x27, 0x26, 0x37
I'm able to convert it statically with some functions:
static byte[] rawbytes = toBytes(0xee, 0x36, 0xe3, 0x57, 0x2b, 0x06, 0x1e, 0x3e, 0x5a, 0x3e, 0xc0, 0x07, 0xab, 0x81, 0xa7, 0x76, 0xa4, 0x27, 0x26, 0x37);
public static byte[] toBytes(int... ints) { // helper function
byte[] result = new byte[ints.length];
for (int i = 0; i < ints.length; i++) {
result[i] = (byte) ints[i];
}
return result;
}
However the problem is that I cannot find a way to create the byte[] at runtime, starting from the String displayed in the logs. Any help? Thanks