In newer Java Versions (since 17) there is HexFormat:
byte byteVal = (byte)HexFormat.of().fromHexDigits("7f");
assert(byteStr.equals("7f"));
assert(b == byteVal);
HexFormat commaFormat = HexFormat.ofDelimiter(", ").withPrefix("#");
byte[] bytes = {0, 1, 2, 3, 124, 125, 126, 127};
String str = commaFormat.formatHex(bytes);
byte[] parsed = commaFormat.parseHex(str);
assert(Arrays.equals(bytes, parsed));
// The formatted string is: "#00, #01, #02, #03, #7c, #7d, #7e, #7f"
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/HexFormat.html