Here you can find the source of byteToHex(byte b[])
public static String byteToHex(byte b[])
//package com.java2s; public class Main { public static String byteToHex(byte b[]) { if (b == null) { throw new IllegalArgumentException("Argument b ( byte array ) is null! "); }/*www . j a v a2 s . c o m*/ 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; } } return hs.toUpperCase(); } }