Here you can find the source of byte2HexStr(byte[] b, int length)
public static String byte2HexStr(byte[] b, int length)
//package com.java2s; public class Main { public static String byte2HexStr(byte[] b, int length) { String hs = ""; String stmp = ""; for (int n = 0; n < length; ++n) { stmp = Integer.toHexString(b[n] & 0xFF); if (stmp.length() == 1) hs = hs + "0" + stmp; else { hs = hs + stmp;/*w w w . ja v a2 s . com*/ } hs = hs + ","; } return hs.toUpperCase(); } }