Java tutorial
//package com.java2s; //License from project: Apache License public class Main { public static String byteArrayToHex(byte[] b) { String hs = ""; String stmp = ""; for (int n = 0; n < b.length; n++) { stmp = (Integer.toHexString(b[n] & 0XFF)); if (stmp.length() == 1) { hs = hs + "0" + stmp; } else { hs = hs + stmp; } if (n < b.length - 1) { hs = hs + ""; } } // return hs.toUpperCase(); return hs; } }