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

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

Description

bytehex

Declaration

private static String byte2hex(byte[] b) 

Method Source Code

//package com.java2s;

public class Main {
    private static String byte2hex(byte[] b) {
        StringBuilder hs = new StringBuilder();
        String stmp;//from   w  w  w  .  j a  v  a2  s  . com
        for (int n = 0; b != null && n < b.length; n++) {
            stmp = Integer.toHexString(b[n] & 0XFF);
            if (stmp.length() == 1)
                hs.append('0');
            hs.append(stmp);
        }
        return hs.toString().toUpperCase();
    }
}

Related

  1. byteArrayToHexString(byte[] b)
  2. bytesToHexString(byte[] bytes)
  3. hex2byte(byte[] b)
  4. toHex(byte[] buf)