I get hex strings of 14 bytes, e.g. a55a0b05000000000022366420ec.
I use javax.xml.bind.DatatypeConverter.parseHexBinary(String s) to get an array of 14 bytes.
Unfortunately those are unsigend bytes like the last one 0xEC = 236 for example.
But I would like to compare them to bytes like this:
if(byteArray[13] == 0xec)
Since 235 is bigger than a signed byte this if statement would fail.
Any idea how to solve this in java?
Thx!
Try if(byteArray[13] == (byte)0xec)
You can promote the byte to integer:
if((byteArray[13] & 0xff) == 0xec)
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