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 input[])
to Hex String
return toHexString(input, input.length);
StringtoHexString(byte n)
INTERNAL: Make hex string for integer.
return "" + toHexDigit((byte) ((n & 0xF0) >> 4)) + toHexDigit((byte) (n & 0x0F));
StringtoHexString(byte value)
to Hex String
return toUnsignedString(value & 0xFF, 4);
StringtoHexString(byte value)
to Hex String
StringBuilder builder = new StringBuilder();
String hex = Integer.toHexString(value & 0xff);
if (hex.length() < 2) {
    builder.append("0");
builder.append(hex);
return builder.toString();
StringtoHexString(byte[] arr)
to Hex String
StringBuilder sb = new StringBuilder();
boolean first = true;
sb.append('[');
for (byte b : arr) {
    if (first)
        first = false;
    else
        sb.append(',');
...
StringtoHexString(byte[] array)
to Hex String
int length = array.length;
StringBuilder hexString = new StringBuilder();
for (int i = 0; i < length; i++) {
    hexString.append(toHexDigit(array[i]));
return hexString.toString();
StringtoHexString(byte[] array)
to Hex String
if (array == null) {
    return "";
StringBuilder sb = new StringBuilder(array.length * 2);
for (byte byt : array) {
    int v = byt & 0xff;
    if (v < 16) {
        sb.append('0');
...
StringtoHexString(byte[] b)
to Hex String
char[] hexChar = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
StringBuilder sb = new StringBuilder(b.length * 2);
for (int i = 0; i < b.length; i++) {
    sb.append(hexChar[(b[i] & 0xf0) >>> 4]);
    sb.append(hexChar[b[i] & 0x0f]);
return sb.toString();
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
StringBuffer sb = new StringBuffer(b.length * 2);
for (int i = 0; i < b.length; i++) {
    sb.append(hexChar[(b[i] & 0xf0) >>> 4]);
    sb.append(hexChar[b[i] & 0x0f]);
return setBinaryLength(sb.toString());