Here you can find the source of bytesToHexStr(byte[] bytes)
private static String bytesToHexStr(byte[] bytes)
//package com.java2s; public class Main { private static String bytesToHexStr(byte[] bytes) { StringBuilder stringBuilder = new StringBuilder(); for (byte b : bytes) { stringBuilder.append(byteToHexStr(b)); }/*from w ww . j a v a2s. c om*/ return stringBuilder.toString(); } private static String byteToHexStr(byte b) { char[] digit = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; char[] tempArr = new char[2]; tempArr[0] = digit[(b >>> 4) & 0x0F]; tempArr[1] = digit[b & 0x0F]; return new String(tempArr); } }