Here you can find the source of toHex(final byte[] bytes)
private static String toHex(final byte[] bytes)
//package com.java2s; //License from project: Apache License public class Main { private static String toHex(final byte[] bytes) { StringBuilder sb = new StringBuilder(bytes.length); for (int i = 0; i < bytes.length; i++) { sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1)); }//from w w w . jav a 2s. c o m return sb.toString(); } }