| Code with Finding: |
class Hex {
/**
* Converts the byte <code>b</code> to capitalized hexadecimal text.
* The result will have length 2 and only contain the characters '0', '1',
* '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'.
*
* @param b the byte to convert.
*
* @return capitalized hexadecimal text representation of <code>b</code>.
*/
public static String byteToHexString(byte b) {
int n = b & 0x000000FF;
String result = (n < 0x00000010 ? "0" : "") + Integer.toHexString(n);
return result.toUpperCase();
}
}
|