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(final byte[] bytes)
Converts a byte-array to a lower case hex-string.
final StringBuilder buf = new StringBuilder(bytes.length * 2);
for (byte b : bytes) {
    buf.append(HEX_CHARS[(b >> 4) & 0xf]);
    buf.append(HEX_CHARS[b & 0xf]);
return buf.toString();
StringtoHexString(final byte[] bytes)
Convert the unsigned byte array to a hexadecimal string.
char[] hexChars = new char[bytes.length * 2];
int value;
for (int index = 0; index < bytes.length; index++) {
    value = bytes[index] & 0xFF;
    hexChars[index * 2] = hexArray[value >> 4];
    hexChars[index * 2 + 1] = hexArray[value & 0x0F];
return new String(hexChars);
...
StringtoHexString(final byte[] bytes)
Builds a Hex-String from a byte array.
final StringBuilder sb = new StringBuilder();
for (final byte b : bytes) {
    sb.append(HEXES.charAt((b & 0xF0) >> 4));
    sb.append(HEXES.charAt(b & 0x0F));
return sb.toString();
StringtoHexString(final byte[] bytes)
to Hex String
final StringBuffer sb = new StringBuffer();
for (final byte b : bytes) {
    byte2hex(b, sb);
return sb.toString();
StringtoHexString(final byte[] bytes)
Converts a given byte input to a hex string.
final StringBuilder builder = new StringBuilder();
for (byte b : bytes) {
    builder.append(BYTE_TO_HEX[b < 0 ? b + 256 : b]);
return builder.toString();
StringtoHexString(final byte[] data)
Converts binary data to string hex representation
final StringBuffer builder = new StringBuffer(2 * data.length);
for (byte item : data) {
    builder.append(HEX_SYMBOLS[(HI_BYTE_MASK & item) >>> 4]);
    builder.append(HEX_SYMBOLS[(LOW_BYTE_MASK & item)]);
return builder.toString();
StringtoHexString(final byte[] data)
Converts an array of bytes into a hexadecimal representation.
final StringBuilder result = new StringBuilder();
for (int i = 0; i < data.length; ++i)
    result.append(Integer.toHexString((data[i] & 0xFF) | 0x100).substring(1, 3));
return result.toString();
StringtoHexString(final byte[] data)
Converts the specified data to hex string.
return toHexString(data, 0, data.length);
StringtoHexString(final byte[] fieldData)
Creates HEX String representation of supplied byte array.
Each byte is represented by a double character element from 00 to ff
StringBuilder sb = new StringBuilder();
for (byte element : fieldData) {
    int v = element & 0xFF;
    if (v <= 0xF) {
        sb.append("0");
    sb.append(Integer.toHexString(v));
return sb.toString();
StringtoHexString(final byte[] raw)
to Hex String
return toHexString(raw, 0, raw.length);