Here you can find the source of toHexString(byte[] bytes)
private static String toHexString(byte[] bytes)
//package com.java2s; public class Main { private static String toHexString(byte[] bytes) { StringBuilder sb = new StringBuilder(); for (byte b : bytes) { int unsignedB = b & 0xff; if (unsignedB < 0x10) sb.append("0"); sb.append(Integer.toHexString(unsignedB)); }// w w w . j ava 2 s. c om return sb.toString(); } }