Java Utililty Methods Integer to Hex

List of utility methods to do Integer to Hex

Description

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

Method

voidint2hex(int a, StringBuffer str)
inthex
str.append(Integer.toHexString(a));
Stringint2hex(int i)
inthex
String s = Integer.toHexString(i / 16) + Integer.toHexString(i % 16);
return s.toUpperCase();
charint2hex(int i)
Converts integer digit to heck char.
return HEX_CHARS[i];
charint2HexChar(int val)
int Hex Char
if (val >= 0 && val < 10) {
    return (char) (val + '0');
if (val >= 10 && val < 16) {
    return (char) (val + 'a' - 10);
return (char) -1;
char[]int2HexChars(final int data)
Method to generate the hexadecimal character presentation of an integer This call is equivalent to HexUtils#int2HexChars(int,char[],int) with parameters (data, null, 0)
return int2HexChars(data, new char[8], 0);
Stringint2HexString(final int i)
Formats an integer as a hex string of little-endian, non-zero-padded bytes.
return bytes2HexString(asByteArray(i >>> 24, i >>> 16, i >>> 8, i));
Stringint2HexString(int n)
int Hex String
return Integer.toHexString(n).toUpperCase();
Stringint2hexString(int x)
inthex String
String s = "";
for (int ii = 0; ii < 8; ii++) {
    s = hex_digit[(x & (15 << (ii * 4))) >>> (ii * 4)] + s;
return s;
voidint2HexString(StringBuilder buf, int value)
This method avoids the use on Integer.toHexString, since this class may be used during the boot-phase when the Integer class in not yet initialized.
int rem = value & 0x0F;
int q = value >>> 4;
if (q != 0) {
    int2HexString(buf, q);
if (rem < 10) {
    buf.append((char) ('0' + rem));
} else {
...
Stringint2HexZeroPad(int i)
int Hex Zero Pad
String hex = int2Hex(i);
if (hex.length() % 2 != 0) {
    hex = "0" + hex;
return hex;