Here you can find the source of toHexString(final byte[] array)
public static String toHexString(final byte[] array)
//package com.java2s; //License from project: Open Source License public class Main { private static final char[] HEX_ARRAY = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; public static String toHexString(final byte[] array) { return toStringHex(array, 0, array.length); }//from www . jav a 2 s. c o m public static String toStringHex(final byte[] array, final int off, final int len) { final char[] result = new char[len << 1]; final int end = off + len; for (int i = off, b, j = 0; i < end; i++) { b = array[i] & 0xff; result[j++] = HEX_ARRAY[b >> 4]; result[j++] = HEX_ARRAY[b & 0x0f]; } return new String(result); } }