Android Utililty Methods Byte Array to Hex Convert

List of utility methods to do Byte Array to Hex Convert

Description

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

Method

StringbyteArr2HexStr(byte[] arrB)
byte Arr Hex Str
int iLen = arrB.length;
StringBuffer sb = new StringBuffer(iLen * 2);
for (int i = 0; i < iLen; i++) {
    int intTmp = arrB[i];
    while (intTmp < 0) {
        intTmp = intTmp + 256;
    if (intTmp < 16) {
...
StringbyteArr2HexStr(byte[] paramArrayOfByte)
byte Arr Hex Str
int i = paramArrayOfByte.length;
StringBuffer localStringBuffer = new StringBuffer(i * 2);
for (int j = 0; j < i; ++j) {
    for (int k = paramArrayOfByte[j]; k < 0; k += 256) {
        if (k < 16)
            localStringBuffer.append("0");
        localStringBuffer.append(Integer.toString(k, 16));
return localStringBuffer.toString();
StringbyteArray2HexString(byte[] data)
byte Array Hex String
StringBuffer sb = new StringBuffer();
for (int i = 0; i < data.length; i++) {
    String temp = Integer.toHexString(data[i] & BYTE_MASK);
    if (temp.length() == 1)
        temp = "0" + temp;
    sb.append(temp);
return sb.toString().toUpperCase();
...
intConvert2bytesHexaFormatToInt(byte[] ArrayToConvert)
Convertbytes Hexa Format To Int
int ConvertedNumber = 0;
if (ArrayToConvert[1] <= -1)
    ConvertedNumber += ArrayToConvert[1] + 256;
else
    ConvertedNumber += ArrayToConvert[1];
if (ArrayToConvert[0] <= -1)
    ConvertedNumber += (ArrayToConvert[0] * 256) + 256;
else
...
StringConvertHexByteArrayToString( byte[] byteArrayToConvert)
Convert Hex Byte Array To String
String ConvertedByte = "";
for (int i = 0; i < byteArrayToConvert.length; i++) {
    if (byteArrayToConvert[i] < 0) {
        ConvertedByte += Integer.toString(
                byteArrayToConvert[i] + 256, 16) + " ";
    } else if (byteArrayToConvert[i] <= 15) {
        ConvertedByte += "0"
                + Integer.toString(byteArrayToConvert[i], 16) + " ";
...
StringtoHex(byte[] array)
Get the hexadecimal representation of a byte array.
return toHex(array, 0, array.length);
StringtoHex(byte[] array, int offset, int len)
Get the hexadecimal representation of a byte array starting at offset index for len bytes.
StringBuilder sb = new StringBuilder();
for (int i = 0; i < len; i++) {
    byte b = array[offset + i];
    sb.append(digits[b >> 4 & 0x0F]);
    sb.append(digits[b & 0x0F]);
return sb.toString();
StringtoHex(byte[] buf)
to Hex
if (buf == null)
    return "";
StringBuffer result = new StringBuffer(2 * buf.length);
for (int i = 0; i < buf.length; i++) {
    appendHex(result, buf[i]);
return result.toString();
StringtoHex(byte[] bytes)
to Hex
StringBuilder sb = new StringBuilder(2 * bytes.length);
for (byte b : bytes) {
    sb.append(hexDigits[(b >> 4) & 0xf]).append(hexDigits[b & 0xf]);
return sb.toString();
StringtoHex(byte[] bytes)
Encodes an array of bytes as hex symbols.
return toHex(bytes, null);