Here you can find the source of toHexString(byte[] bytes)
private static String toHexString(byte[] bytes)
//package com.java2s; //License from project: Apache License public class Main { private static final char[] LETTERS = "0123456789ABCDEF".toCharArray(); private static String toHexString(byte[] bytes) { char[] values = new char[bytes.length * 2]; int i = 0; for (byte b : bytes) { values[i++] = LETTERS[((b & 0xF0) >>> 4)]; values[i++] = LETTERS[b & 0xF]; }//from ww w . ja v a2 s .c om return String.valueOf(values); } }