Java tutorial
//package com.java2s; public class Main { public static String hexString(byte[] bytes) { StringBuffer hexValue = new StringBuffer(); for (int i = 0; i < bytes.length; i++) { int val = ((int) bytes[i]) & 0xff; if (val < 16) hexValue.append("0"); hexValue.append(Integer.toHexString(val)); } return hexValue.toString(); } }