I have a hex string,st=”9e”. I need to convert it into byte and insert it in the byte array. But i am not able to cast from string to byte. I have used techniques like
1) Byte.valueOf(str);
2) new Byte(str);
3) Tried appending “0X” to str and then converting to byte.
All these gave errors.
Can you tell me how to cast from string to byte.
You may be looking for something like this:
Since bytes are signed integral types, you’ll need to convert them to unsigned values.