Android Utililty Methods Hex String Create

List of utility methods to do Hex String Create

Description

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

Method

inttoHex(int address)
to Hex
return address - 0xC00000 + 0x200;
byte[]toHexByte(String str, int offset, int length)
to Hex Byte
byte[] data = new byte[(length - offset) * 2];
int end = offset + length;
int high_nibble;
int low_nibble;
for (int i = offset; i < end; i++) {
    char ch = str.charAt(i);
    high_nibble = (ch & 0xF0) >>> 4;
    low_nibble = ch & 0x0F;
...
chartoHexChar(int i)
Convenience method to convert an int to a hex char.
if ((0 <= i) && (i <= 9)) {
    return (char) ('0' + i);
} else {
    return (char) ('a' + (i - 10));
StringtoHexDigits(byte theByte)
Private replacement for toHexString since we need the leading 0 digits.
final char[] HEXDIGITS = { '0', '1', '2', '3', '4', '5', '6', '7',
        '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
StringBuilder result = new StringBuilder(2);
result.append(HEXDIGITS[(theByte >>> 4) & 15]);
result.append(HEXDIGITS[theByte & 15]);
return result.toString();
StringtoHexDigits(byte[] bytes)
to Hex Digits
StringBuilder encoded = new StringBuilder(bytes.length * 2);
for (byte aByte : bytes) {
    encoded.append(toHexDigits(aByte).toUpperCase());
return encoded.toString();
StringtoHexString(byte oneByte)
to Hex String
return String.format("%02x", oneByte);
Stringbt64ToHex(int[] byteData)
bt To Hex
String hex = "";
for (int i = 0; i < 16; i++) {
    String bt = "";
    for (int j = 0; j < 4; j++) {
        bt += byteData[i * 4 + j];
    hex += bt4ToHex(bt);
return hex;