Java Utililty Methods Byte to Hex

List of utility methods to do Byte to Hex

Description

The list of methods to do Byte to Hex are organized into topic(s).

Method

StringbyteToHex(final byte b)
Retrieves a string representation of the provided byte in hexadecimal.
return BYTE_HEX_STRINGS[UPPER_CASE][b & 0xFF];
StringbyteToHex(final byte b)
Convert a byte to it's hexadecimal equivalent.
return Integer.toHexString(b & MINUS_ONE);
voidbyteToHex(final byte b, StringBuilder buffer)
byte To Hex
int i = b & 0xFF;
buffer.append(_hex[i >>> 4]);
buffer.append(_hex[i & 0x0F]);
StringbyteToHex(final byte value)
byte To Hex
if ((value & 0xFF) < 16) {
    return "0" + Integer.toHexString(value & 0xFF);
} else {
    return Integer.toHexString(value & 0xFF);
StringbyteToHex(final byte value, final int minLength)
byte To Hex
String hex = Integer.toHexString(value & 0xff);
if (hex.length() < minLength) {
    for (int i = 0; i < (minLength - hex.length()); i++)
        hex = '0' + hex;
return hex;
StringbyteToHex(final byte[] data)
byte To Hex
final StringBuilder hex = new StringBuilder();
for (int i = 0; i < data.length; i++) {
    hex.append(String.format("%02x", data[i]));
return hex.toString();
StringbyteToHex(int v)
Returns a two char hexadecimal String representation of a single byte.
String hstr;
hstr = Integer.toString(v & 0xff, 16);
return hstr.length() == 1 ? "0" + hstr : hstr;