Here you can find the source of bytes2Hex(byte[] bytes)
public static String bytes2Hex(byte[] bytes)
//package com.java2s; //License from project: Open Source License public class Main { public static String bytes2Hex(byte[] bytes) { StringBuffer ret = new StringBuffer(bytes.length * 2); for (int i = 0; i < bytes.length; i++) { ret.append(byte2Hex(bytes[i])); }//from www .j a v a2 s . c o m return ret.toString(); } static public String byte2Hex(byte b) { // Returns hex String representation of byte b final char hexDigit[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; char[] array = { hexDigit[(b >> 4) & 0x0f], hexDigit[b & 0x0f] }; return new String(array); } }