Java tutorial
//package com.java2s; public class Main { private static String getHexString(byte[] b) { StringBuffer strb = new StringBuffer(); int temp; for (int i = 0; i < b.length; i++) { temp = 0xFF & b[i]; if (temp <= 0xF) { strb.append('0'); } strb.append(b[i]); } return strb.toString(); } }