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