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

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

Description

bytehex

Declaration

public static String byte2hex(byte[] b) 

Method Source Code

//package com.java2s;

public class Main {
    public static String byte2hex(byte[] b) {
        String hs = "";
        String stmp = "";

        for (int n = 0; n < b.length; n++) {
            stmp = (java.lang.Integer.toHexString(b[n] & 0XFF));
            if (stmp.length() == 1)
                hs = hs + "0" + stmp;
            else// w  w  w. j a  va 2 s .c o m
                hs = hs + stmp;
        }
        return hs.toUpperCase();
    }
}

Related

  1. byteArrayToHexString(byte[] data)
  2. bytesToHexString(byte[] bArray)
  3. toHexadecimealString(byte[] data)
  4. bytesToHex(byte[] bytes)
  5. byte2hex(byte buffer)
  6. byte2hex(byte[] buffer)
  7. byte2hex(byte[] buffer, int len)
  8. byte2hexWithoutSpace(byte[] buffer)
  9. byteArrayToHexString(byte[] b)