Java tutorial
//package com.java2s; public class Main { public static String byte2hex(byte[] b) { StringBuffer sb = new StringBuffer(); String stmp = ""; for (int n = 0; n < b.length; n++) { stmp = Integer.toHexString(b[n] & 0XFF); if (stmp.length() == 1) { sb.append("0" + stmp); } else { sb.append(stmp); } } return sb.toString(); } }