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