Here you can find the source of byte2hex(byte[] b)
private static String byte2hex(byte[] b)
//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(); } }