Here you can find the source of bytes2hexStr(byte[] arr, int len)
public final static String bytes2hexStr(byte[] arr, int len)
//package com.java2s; public class Main { static final char[] hex = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; /**//from www . j ava 2 s . c om * Function: <tt>bytes2hexStr (byte [] arr, int len)(</tt> * Generate a hex string showing the value of the bytes in ARR. * (Used by me for testing this class.) */ public final static String bytes2hexStr(byte[] arr, int len) { StringBuffer sb = new StringBuffer(len * 2); for (int i = 0; i < len; i++) { int hi = (arr[i] >>> 4) & 0xf; sb.append(hex[hi]); int low = (arr[i]) & 0xf; sb.append(hex[low]); } return sb.toString(); } public static String bytes2hexStr(byte[] arr) { return bytes2hexStr(arr, arr.length); } }