import java.util.*;
byte[] bytes = { 1, 15, (byte) 255 };
// *** before: ***
StringBuilder sb = new StringBuilder();
for (byte b : bytes) {
sb.append(String.format("%02x", b));
}
System.out.println(sb); // 010fff
// *** in version 17: ***
HexFormat hex = HexFormat.of();
System.out.println(hex.formatHex(bytes)); // 010fff
System.out.println(Arrays.toString(hex.parseHex("010fff")));
HexFormat pretty = HexFormat.ofDelimiter(":").withUpperCase();
System.out.println(pretty.formatHex(bytes)); // 01:0F:FF
System.out.println(HexFormat.fromHexDigits("ff")); // 255