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

StringtoHexStream(byte[] bytes, String delimiter, boolean prefixEachValue, boolean upperCase)
Produces a hex stream where bytes are separated by delimiter, and optionally prefixed with "0x" if prefixEachValue is true.
StringBuilder sb = new StringBuilder();
appendHexStream(sb, bytes, delimiter, prefixEachValue, upperCase);
return sb.toString();
StringtoHexString(byte a)
to Hex String
StringBuffer sb = new StringBuffer(2);
sb.append(NIBBLE[(a >>> 4) & 0xf]);
sb.append(NIBBLE[a & 0xf]);
return sb.toString();
StringtoHexString(byte abyte0[], boolean spaceFlag)
to Hex String
if (null == abyte0)
    return null;
return toHexString(abyte0, 0, abyte0.length, spaceFlag);
StringtoHexString(byte b)
to Hex String
StringBuffer buf = new StringBuffer();
char[] hexChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
int high = 0;
int low = 0;
high = ((b & 0xf0) >> 4);
low = (b & 0x0f);
buf.append(hexChars[high]);
buf.append(hexChars[low]);
...
StringtoHexString(byte b)
to Hex String
return toHexString(new byte[] { b }, 0, 1);
StringtoHexString(byte b)
Format a byte into a proper length hex String.
return toHexString(unsignedLong(b), '0', 2, 2);
StringtoHexString(byte b)
to Hex String
String hex = Integer.toHexString(b);
int len = hex.length();
if (len == 2) {
    return hex;
} else if (len == 1) {
    return "0" + hex;
} else {
    return hex.substring(len - 2);
...
StringtoHexString(byte b)
Convert a byte value into a 2-digits hexadecimal value.
int n = (b < 0) ? b + 256 : b;
StringBuilder sb = new StringBuilder();
sb.append(hexDigits[n / 16]);
sb.append(hexDigits[n % 16]);
return sb.toString();
StringtoHexString(byte b)
to Hex String
int base;
String s;
base = ((int) b) & 0xFF;
s = Integer.toHexString(base);
if (base < 16)
    s = "0" + s;
return (s);
StringtoHexString(byte b)
to Hex String
return toHexString(new byte[] { b });