Java tutorial
//package com.java2s; public class Main { public static String byte2hex(byte[] bytes) throws Exception { try { String hs = ""; String stmp = ""; for (int i = 0; i < bytes.length; i++) { stmp = (java.lang.Integer.toHexString(bytes[i] & 0XFF)); if (stmp.length() == 1) hs = hs + "0" + stmp; else hs = hs + stmp; } return hs.toUpperCase(); } catch (Exception e) { throw new Exception(e); } } }