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

StringtoHexString(byte b)
toHexString.
char[] chars = new char[2];
int d = (b & 0xF0) >> 4;
int m = b & 0x0F;
chars[0] = hexTable[d];
chars[1] = hexTable[m];
return new String(chars);
StringtoHexString(byte b)
Convert a byte into Hex string
String s = Integer.toHexString(b);
s = s.toUpperCase();
StringBuffer sb = new StringBuffer();
int len = s.length();
if (len == 1) {
    sb.append("0").append(s);
} else if (len == 2) {
    sb.append(s);
...
StringtoHexString(byte b)
to Hex String
StringBuffer sb = new StringBuffer("00");
sb.append(Integer.toHexString(b));
return sb.substring(sb.length() - 2);
StringtoHexString(byte b)
Returns the string representation of a byte.
return toHexString(null, b).toString();
StringtoHexString(byte b)
to Hex String
String s = Integer.toHexString(b & 0xFF).toUpperCase();
return (s.length() == 2) ? (s) : ("0" + s);
StringtoHexString(byte b)
to Hex String
String hex = Integer.toHexString((int) b & 0xff);
if (hex.length() == 1) {
    return ('0' + hex);
} else {
    return hex;
StringtoHexString(byte b)
to Hex String
StringBuffer result = new StringBuffer(3);
result.append(Integer.toString((b & 0xF0) >> 4, 16));
result.append(Integer.toString(b & 0x0F, 16));
return result.toString();
StringtoHexString(byte b[])
to Hex String
StringBuffer hexString = new StringBuffer();
for (int i = 0; i < b.length; i++) {
    String plainText = Integer.toHexString(0xff & b[i]);
    if (plainText.length() < 2)
        plainText = "0" + plainText;
    hexString.append(plainText);
return hexString.toString();
...
StringtoHexString(byte b[])
convert an array of bytes to an hexadecimal string
int pos = 0;
char[] c = new char[b.length * 2];
for (int i = 0; i < b.length; i++) {
    c[pos++] = toHex[(b[i] >> 4) & 0x0F];
    c[pos++] = toHex[b[i] & 0x0f];
return new String(c);
StringtoHexString(byte b[])
to Hex String
StringBuffer sb = new StringBuffer();
for (int i = 0; i < b.length; i++) {
    sb.append(HEX_CHARS.charAt(b[i] >>> 4 & 0xf));
    sb.append(HEX_CHARS.charAt(b[i] & 0xf));
return sb.toString();