Here you can find the source of bytes_to_hex(byte[] bytes)
private static String bytes_to_hex(byte[] bytes)
//package com.java2s; //License from project: Apache License public class Main { final private static char[] hexArray = "0123456789ABCDEF".toCharArray(); private static String bytes_to_hex(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 va 2 s . c o m*/ return new String(hexChars); } }