Here you can find the source of bytesToHexString(byte[] bytes)
private static String bytesToHexString(byte[] bytes)
//package com.java2s; //License from project: Apache License public class Main { private static final char[] DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; private static String bytesToHexString(byte[] bytes) { final char[] buf = new char[bytes.length * 2]; byte b;//w w w . j av a 2 s .c o m int c = 0; for (int i = 0, z = bytes.length; i < z; i++) { b = bytes[i]; buf[c++] = DIGITS[(b >> 4) & 0xf]; buf[c++] = DIGITS[b & 0xf]; } return new String(buf); } }