Reputation: 1259
I have a hex string and in python there is a method a2b_hex from binacii. I want an example to make the same in java.
Upvotes: 2
Views: 3238
Reputation: 11534
You can convert a hex string to a byte array with DatatypeConverter.parseHexBinary
:
import javax.xml.bind.DatatypeConverter;
String hexString = "dead";
byte[] bytes = DatatypeConverter.parseHexBinary(hexString);
Upvotes: 2