Here you can find the source of toHex(byte[] bytes)
public static String toHex(byte[] bytes)
//package com.java2s; //License from project: Apache License public class Main { final protected static char[] _hexArray = "0123456789ABCDEF".toCharArray(); public static String toHex(byte[] bytes) { char[] hexChars = new char[bytes.length * 2]; for (int j = 0; j < bytes.length; j++) { int v = bytes[j] & 0xFF; hexChars[j * 2] = _hexArray[v >>> 4]; hexChars[j * 2 + 1] = _hexArray[v & 0x0F]; }//from w w w . ja v a 2s . c o m return new String(hexChars); } }