Java Utililty Methods Hex Calculate

List of utility methods to do Hex Calculate

Description

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

Method

StringtoHex(boolean[] bits)
Returns the hexadecimal number of a bit array .
int retVal = 0;
for (int i = 0; i < bits.length; ++i) {
    retVal |= (bits[i] ? 1 : 0) << i;
return toHex(retVal);
StringtoHex(byte b)
to Hex
b += 0x80;
int hb = (b & 0xF0) >> 4;
int lb = b & 0x0F;
return toHex(hb) + toHex(lb);
StringtoHex(byte b)
to Hex
char[] characters = new char[2];
characters[0] = HEX_VALUES[(b >>> 4) & 0x0F];
characters[1] = HEX_VALUES[b & 0x0F];
return new String(characters);
StringtoHex(byte b)
toHex converts a byte into a readable string.
StringBuffer sb = new StringBuffer();
int upper = (b >> 4) & 0x0F;
sb.append(lookup[upper]);
int lower = b & 0x0F;
sb.append(lookup[lower]);
sb.append(' ');
return sb.toString();
Stringtohex(byte b)
tohex
if (b == 0)
    return "0";
else if (b == 1)
    return "1";
else if (b == 2)
    return "2";
else if (b == 3)
    return "3";
...
StringtoHex(byte b)
Return Hex String representation of byte b
char hexDigit[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
char[] array = { hexDigit[(b >> 4) & 0x0f], hexDigit[b & 0x0f] };
return new String(array);
StringtoHex(byte b)
to Hex
char[] buf = new char[2];
for (int i = 0; i < 2; i++) {
    b = (byte) (b >>> 4);
return new String(buf);
StringtoHex(byte b)
to Hex
char[] c = new char[2];
int v = b & 0xFF;
c[0] = hexArray[v >>> 4];
c[1] = hexArray[v & 0x0F];
return new String(c);
StringtoHex(byte b)
to Hex
String hex = Integer.toString((int) b & 0xFF, 16);
if (hex.length() < 2)
    hex = "0" + hex;
return hex;
StringtoHex(byte b)
to Hex
return "" + "0123456789ABCDEF".charAt(0xf & b >> 4) + "0123456789ABCDEF".charAt(b & 0xf);