Here you can find the source of bytesToHex(byte[] bytes)
private static String bytesToHex(byte[] bytes)
//package com.java2s; //License from project: Open Source License public class Main { private static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; private static String bytesToHex(byte[] bytes) { int len = bytes.length; StringBuilder buf = new StringBuilder(len * 2); for (int j = 0; j < len; j++) { buf.append(HEX_DIGITS[(bytes[j] >> 4) & 0x0f]); buf.append(HEX_DIGITS[bytes[j] & 0x0f]); }//w w w. j a v a 2 s. c o m return buf.toString(); } }