Java Utililty Methods Hex Print

List of utility methods to do Hex Print

Description

The list of methods to do Hex Print are organized into topic(s).

Method

StringprintHexNumber(int n)
Returns number in 0xABCDEF-Format
return "0x" + Integer.toHexString(n).toUpperCase();
StringprintHexString(byte[] b)
print Hex String
String str = "";
for (int i = 0; i < b.length; i++) {
    String hex = Integer.toHexString(b[i] & 0xFF);
    if (hex.length() == 1) {
        hex = '0' + hex;
    str += hex.toUpperCase();
return str;
voidprintHexString(final StringBuilder sb, final String hexData)
Formats hex dta into 64 byte rows.
int rem = hexData.length();
int curs = 0;
while (rem >= 64) {
    sb.append(String.format("%8d: ", curs));
    sb.append(hexData.substring(curs, curs + 64) + "\n");
    curs += 64;
    rem -= 64;