Here you can find the source of toHex(final byte[] bytes)
public static String toHex(final byte[] bytes)
//package com.java2s; public class Main { public final static char[] hex = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; public static String toHex(final byte[] bytes) { final char[] buffer = new char[bytes.length * 2]; for (int i = 0; i < bytes.length; i++) { buffer[i * 2] = hex[(bytes[i] & 0xf0) >> 4]; buffer[i * 2 + 1] = hex[bytes[i] & 0xf]; }//from w w w . ja va 2s.c o m return new String(buffer); } }