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)
Format a byte array as a hexadecimal string.
if (b == null) {
    return "null";
StringBuffer ret = new StringBuffer(b.length);
for (int i = 0; i < b.length; i++) {
    String hex = Integer.toHexString(0x0100 + (b[i] & 0x00FF)).substring(1);
    ret.append((hex.length() < 2 ? "0" : "") + hex);
return ret.toString();
StringtoHexString(byte[] b)
translate byte array to Hex String .
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < b.length; ++i) {
    buffer.append(toHexString(b[i]));
return buffer.toString();
StringtoHexString(byte[] b)
Returns the hexadecimal representation of the byte array (uppercase).
if (b == null) {
    return null;
char[] buf = new char[b.length * 2];
int j, k;
j = 0;
for (int i = 0; i < b.length; i++) {
    k = b[i];
...
StringtoHexString(byte[] b)
to Hex String
return toHexString(b, b.length);
StringtoHexString(byte[] b)
to Hex String
StringBuffer buf = new StringBuffer();
for (int i = 0; i < b.length; i++) {
    int bi = 0xff & b[i];
    int c = '0' + (bi / 16) % 16;
    if (c > '9')
        c = 'A' + (c - '0' - 10);
    buf.append((char) c);
    c = '0' + bi % 16;
...
StringtoHexString(byte[] b)
to Hex String
int n;
String result = "";
for (byte x : b) {
    n = (x & 0xF0) >> 4;
    result += nibbleToChar(n);
    n = x & 0x0F;
    result += nibbleToChar(n);
return result;
StringtoHexString(byte[] b)
Return hex string of bytes.
StringBuffer s = new StringBuffer();
for (int i = 0; i < b.length; ++i)
    s.append(byteToHexString(b[i]));
return s.toString();
StringtoHexString(byte[] b)
to Hex String
if (b == null) {
    return "";
StringBuffer sb = new StringBuffer(b.length * 2);
for (int i = 0; i < b.length; i++) {
    byte bb = b[i];
    String oneByteString = toHexString(bb);
    sb.append(oneByteString);
...
StringtoHexString(byte[] b)
to Hex String
StringBuffer resultSb = new StringBuffer();
for (int i = 0; i < b.length; i++) {
    resultSb.append(byteToHexString(b[i]));
return resultSb.toString();
StringtoHexString(byte[] b)
to Hex String
StringBuilder s = new StringBuilder(2 * b.length);
for (byte aB : b) {
    int v = aB & 0xff;
    s.append((char) Hexhars[v >> 4]);
    s.append((char) Hexhars[v & 0xf]);
return s.toString();