Android Byte Array to Hex Convert byte2HexStr(byte[] b)

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

Description

byte Hex Str

Declaration

public static String byte2HexStr(byte[] b) 

Method Source Code

//package com.java2s;

public class Main {

    public static String byte2HexStr(byte[] b) {
        String hs = "0x";
        String stmp = "";
        for (int n = 0; n < b.length; n++) {
            stmp = (Integer.toHexString(b[n] & 0XFF));
            if (stmp.length() == 1)
                hs = hs + "0" + stmp;
            else/*from ww w.  j av  a  2  s  . co  m*/
                hs = hs + stmp;
            hs = hs + ", 0x";
        }
        return hs.toUpperCase();
    }
}

Related

  1. bytesToHex(byte[] data, int offset, int length)
  2. bytesToHexString(byte[] bytes)
  3. bytesToHexString(byte[] bytes)
  4. bytesToHexString(byte[] bytes)
  5. bytesToHexString(byte[] bytes)
  6. byte2HexStr(byte[] b, int length)
  7. byte2HexString(byte[] b)
  8. byte2Hext(byte bin)
  9. byteArr2HexStr(byte[] arr)