Here you can find the source of byte2hex(byte[] b)
public static String byte2hex(byte[] b)
//package com.java2s; public class Main { public static String byte2hex(byte[] b) { StringBuffer sb = new StringBuffer(b.length * 2); String tmp = ""; for (int n = 0; n < b.length; n++) { tmp = (java.lang.Integer.toHexString(b[n] & 0XFF)); if (tmp.length() == 1) { sb.append("0"); }/* w ww .j av a 2 s .com*/ sb.append(tmp); } return sb.toString().toUpperCase(); } }