Java tutorial
//package com.java2s; public class Main { public static String toHex(byte[] bytes) { StringBuffer buf = new StringBuffer(""); String tmp = null; for (int i = 0; i < bytes.length; i++) { tmp = (Integer.toHexString(bytes[i] & 0xFF)); if (tmp.length() == 1) { buf.append("0"); } buf.append(tmp); } return buf.toString(); } }