Here you can find the source of toHex(byte[] bytes)
public static String toHex(byte[] bytes)
//package com.java2s; //License from project: Open Source License public class Main { public final static char[] HEX_VALUES = "0123456789ABCDEF".toCharArray(); public static String toHex(byte[] bytes) { StringBuilder buf = new StringBuilder(); for (int i = 0; i < bytes.length; i++) { byte b = bytes[i]; int fnibble = (b >> 4); int snibble = 0x0f & b; buf.append(HEX_VALUES[fnibble]); buf.append(HEX_VALUES[snibble]); }// www . j a v a 2s . c o m return buf.toString(); } }