Android Byte Array to String Convert byteArrayToString(byte[] b)

Here you can find the source of byteArrayToString(byte[] b)

Description

byte Array To String

Declaration

public static String byteArrayToString(byte[] b) 

Method Source Code

//package com.java2s;

public class Main {
    private final static String[] hexDigits = { "0", "1", "2", "3", "4",
            "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };

    public static String byteArrayToString(byte[] b) {
        StringBuffer resultSb = new StringBuffer();
        for (int i = 0; i < b.length; i++) {
            resultSb.append(byteToHexString(b[i]));
        }/* www .  jav a2s.c  o  m*/
        return resultSb.toString();
    }

    private static String byteToHexString(byte b) {
        int n = b;
        if (n < 0) {
            n = 256 + n;
        }
        int d1 = n / 16;
        int d2 = n % 16;
        return hexDigits[d1] + hexDigits[d2];
    }
}

Related

  1. getStringForByte(byte[] bs)
  2. fromBytes(byte abyte0[])
  3. toString(byte[] b, int start, int end)
  4. Bcd2Str(byte[] b)
  5. ByteArrayToString(byte[] input)
  6. byteArrayToString(byte[] bytes)
  7. byteToString(byte b)
  8. bytes2String(byte[] data)
  9. bytes2String(byte[] data, String type)