How can I convert an int value to a one byte hex.
I have tried the following but it is returning a two byte value.
Integer.toHexString(intValue);
I am trying to send a one byte hex value inside a message. What I do is construct the message, calculate an inValue and then try to convert it as a hex and add it into it. This message is finally sent as a stream of bytes.
For example:
The message structure is like this:
Message: "\u0003"|Integer.toHexString(intValue)|BODY|"\u0004"
I need to add this inValue as a hex. Moreover, I need it to be sent as a one byte hex value.
When I use the above method to get the hex value I end up with a stream of bytes that looks like this:
3
36 <-- The first part of the hex value.
36 <-- The second part of the hex value.
xx
xx
...
4
What I need instead is this:
3
36 <-- Only one hex value as one byte.
xx
xx
...
4
How can I achieve that?
Thanks,
B.D.