Android Utililty Methods Byte to Hex Convert

List of utility methods to do Byte to Hex Convert

Description

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

Method

voidappendHex(StringBuffer sb, byte b)
append Hex
sb.append(HEX.charAt((b >> 4) & 0x0f)).append(HEX.charAt(b & 0x0f));
StringtoHexString(byte abyte0)
to Hex String
StringBuffer sbuf = new StringBuffer();
appendHex(sbuf, abyte0);
String returnString = sbuf.toString();
sbuf = null;
return returnString;
StringbyteToHexString(byte b)
byte To Hex String
int n = b;
if (n < 0)
    n = 256 + n;
int d1 = n / 16;
int d2 = n % 16;
return hexDigits[d1] + hexDigits[d2];
StringgetHexString(byte i)
get Hex String
return getHexString(new byte[] { i });
StringtoHexString(byte b)
to Hex String
StringBuffer result = new StringBuffer(3);
result.append(Integer.toString((b & 0xF0) >> 4, 16));
result.append(Integer.toString(b & 0x0F, 16));
return result.toString();
StringtoHexString(byte byt)
to Hex String
String result = null;
int high_nibble;
int low_nibble;
high_nibble = (byt & 0xF0) >>> 4;
low_nibble = (byt & 0x0F);
result = "" + HEXS[high_nibble] + HEXS[low_nibble];
return result;
StringgetBinaryStrFromByte(byte b)
get Binary Str From Byte
String result = "";
byte a = b;
for (int i = 0; i < 8; i++) {
    result = (a % 2) + result;
    a = (byte) (a >> 1);
return result;
StringgetBinaryString(byte src)
7 => 00000111
String binaryString = Integer.toBinaryString(src);
if (binaryString.length() > Byte.SIZE) {
    binaryString = binaryString.substring(binaryString.length()
            - Byte.SIZE);
} else {
    String temp = "";
    for (int i = 0; i < Byte.SIZE - binaryString.length(); i++) {
        temp += "0";
...
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 data)
method to convert a byte to a hex string.
StringBuffer buf = new StringBuffer();
buf.append(toHexChar((data >>> 4) & 0x0F));
buf.append(toHexChar(data & 0x0F) + " ");
return buf.toString();