Java tutorial
//package com.java2s; //License from project: Apache License public class Main { public static String toHexString(byte[] b) { if (b == null) return null; StringBuilder sb = new StringBuilder(b.length * 2); for (int i = 0; i < b.length; i++) { int v = b[i] & 0xFF; String hv = Integer.toHexString(v); if (hv.length() < 2) { sb.append(0); } sb.append(hv); } return sb.toString(); } }