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(byte b)
byte To Hex
char hexDigit[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
char[] array = { hexDigit[(b >> 4) & 0x0f], hexDigit[b & 0x0f] };
return new String(array);
StringbyteToHex(byte b)
Converts a byte to a hexadecimal string.
String str = "";
if (((int) b & 0xff) < 0x10) {
    str += "0";
str += Long.toString((int) b & 0xff, 16);
return str.toUpperCase();
StringbyteToHex(byte b)
byte To Hex
int v = b & 0xFF;
return new String(new char[] { hexArray[v >>> 4], hexArray[v & 0x0F] });
voidbyteToHex(byte b, StringBuffer buf)
byte To Hex
char[] hexChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
int high = ((b & 0xf0) >> 4);
int low = (b & 0x0f);
buf.append(hexChars[high]);
buf.append(hexChars[low]);
StringbyteToHex(byte bytevalue)
byte To Hex
final char[] hexArray = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
int v = bytevalue & 0xFF;
return new String(new char[] { hexArray[v >>> 4], hexArray[v & 0x0F] });
StringByteToHex(byte byyte)
Byte To Hex
char[] hexChars = new char[2];
int v = byyte & 0xFF;
hexChars[0] = hexArray[v >>> 4];
hexChars[1] = hexArray[v & 0x0F];
return new String(hexChars);
StringbyteToHex(byte c)
Returns the hexadecimal string representation of a by
int l = (c & 0x0f);
int h = (c & 0xf0) >> 4;
char H;
char L;
H = h < 0x0A ? (char) (0x30 + h) : (char) (0x41 + (h - 0x0A));
L = l < 0x0A ? (char) (0x30 + l) : (char) (0x41 + (l - 0x0A));
return "" + H + L;
StringbyteToHex(byte[] bytes)
byte To Hex
String hex = "";
for (int i = 0; i < bytes.length; i++) {
    hex += Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1);
return hex;
StringbyteToHex(byte[] data)
Converts the content of a byte array into a human readable form.
StringBuilder sb = new StringBuilder();
for (byte b : data) {
    sb.append(String.format("%02X", b));
return sb.toString();
StringbyteToHex(char val)
Convert a byte to its hexadecimal value.
int hi = (val & 0xF0) >> 4;
int lo = (val & 0x0F);
return "" + HEX.charAt(hi) + HEX.charAt(lo);