Here you can find the source of byteArr2HexStr(byte[] arrB)
public static String byteArr2HexStr(byte[] arrB) throws Exception
//package com.java2s; public class Main { public static String byteArr2HexStr(byte[] arrB) throws Exception { int iLen = arrB.length; StringBuffer sb = new StringBuffer(iLen * 2); for (int i = 0; i < iLen; i++) { int intTmp = arrB[i]; while (intTmp < 0) { intTmp = intTmp + 256;//w w w. j a va 2s .c o m } if (intTmp < 16) { sb.append("0"); } sb.append(Integer.toString(intTmp, 16)); } return sb.toString(); } }