Here you can find the source of toHexString(final byte[] raw)
public static String toHexString(final byte[] raw)
//package com.java2s; //License from project: Open Source License public class Main { static final byte[] HEX_CHAR_TABLE = { (byte) '0', (byte) '1', (byte) '2', (byte) '3', (byte) '4', (byte) '5', (byte) '6', (byte) '7', (byte) '8', (byte) '9', (byte) 'A', (byte) 'B', (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F' }; public static String toHexString(final byte[] raw) { return toHexString(raw, 0, raw.length); }/*w ww . ja v a 2 s. co m*/ public static String toHexString(final byte[] raw, final int offset, final int length) { final byte[] hex = new byte[2 * length]; int index = 0; for (int i = 0; i < length; i++) { final int v = raw[i + offset] & 0xFF; hex[index++] = HEX_CHAR_TABLE[v >>> 4]; hex[index++] = HEX_CHAR_TABLE[v & 0xF]; } return new String(hex); } public static String toHexString(final int value, final int minDigits) { String hexString = Integer.toHexString(value); for (int i = minDigits - hexString.length(); i > 0; i--) { hexString = "0" + hexString; } return hexString.toUpperCase(); } }