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

StringtoHexString(byte[] bytes, int offset, int length)
to Hex String
if (bytes == null) {
    return null;
StringBuffer result = new StringBuffer();
for (int i = offset; i < offset + length; i++) {
    result.append(Integer.toString((bytes[i] & 0xF0) >> 4, 16));
    result.append(Integer.toString(bytes[i] & 0x0F, 16));
return result.toString();
StringtoHexString(byte[] data)
Converts a byte array into a String of its hexadecimal representation.
int c;
String res = "", s;
for (byte aux : data) {
    c = aux & 0xff;
    s = Integer.toHexString(c);
    if (s.length() == 1)
        res += "0";
    res += s;
...
StringtoHexString(byte[] data, int offset, int length)
to Hex String
StringBuilder s = new StringBuilder(length * 2);
int end = offset + length;
int high_nibble;
int low_nibble;
for (int i = offset; i < end; i++) {
    high_nibble = (data[i] & 0xF0) >>> 4;
    low_nibble = (data[i] & 0x0F);
    s.append(HEXS[high_nibble]);
...
String[]toHexStringArray(byte[] data, int offset, int length)
to Hex String Array
String[] result = new String[length];
StringBuilder s = new StringBuilder(length * 2);
int end = offset + length;
int high_nibble;
int low_nibble;
for (int i = offset, j = 0, k = 0; i < end; i++, j++, k += 2) {
    high_nibble = (data[i] & 0xF0) >>> 4;
    low_nibble = (data[i] & 0x0F);
...
StringconvertToHexString(byte[] input)
Converts a byte array into a hexadecimal string.
if (input == null || input.length == 0) {
    return new String();
StringBuilder sb = new StringBuilder();
for (byte b : input) {
    sb.append(String.format(Locale.ENGLISH, "%02x", b & 0xff));
return sb.toString().toLowerCase(Locale.ENGLISH);
...
StringdumpHex(byte[] bytes)
dump Hex
return bytesToHex(bytes);
StringgetBinaryStrFromByteArr(byte[] bArr)
get Binary Str From Byte Arr
String result = "";
for (byte b : bArr) {
    result += getBinaryStrFromByte(b);
return result;
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[] buf)
Retrieve the string format of a byte data.
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();
Stringbyte2hex(byte[] b)
bytehex
StringBuffer sb = new StringBuffer(b.length * 2);
String tmp = "";
for (int n = 0; n < b.length; n++) {
    tmp = (java.lang.Integer.toHexString(b[n] & 0XFF));
    if (tmp.length() == 1) {
        sb.append("0");
    sb.append(tmp);
...