Here you can find the source of toHexString(byte[] bytes)
public static String toHexString(byte[] bytes)
//package com.java2s; //License from project: Apache License public class Main { private static String[] int2Hex = new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", }; /**/*w ww.jav a 2 s . c o m*/ * Convert bytes to hex string. * */ public static String toHexString(byte[] bytes) { StringBuilder sb = new StringBuilder(); for (byte b : bytes) { sb.append(toHexString(b) + " "); } return sb.toString(); } /** * Convert byte to hex string. * */ private static String toHexString(byte b) { StringBuilder sb = new StringBuilder(); int r1 = (b >>> 4) & 0xF; sb.append(int2Hex[r1]); int r2 = b & 0xF; sb.append(int2Hex[r2]); return sb.toString(); } }