[java] Java code To convert byte to Hexadecimal

If you want a constant-width hex representation, i.e. 0A instead of A, so that you can recover the bytes unambiguously, try format():

StringBuilder result = new StringBuilder();
for (byte bb : byteArray) {
    result.append(String.format("%02X", bb));
}
return result.toString();