Here you can find the source of bytesToHex(byte[] bytes)
public static String bytesToHex(byte[] bytes)
//package com.java2s; //License from project: Open Source License public class Main { private static final char[] HEX = "0123456789abcdef".toCharArray(); public static String bytesToHex(byte[] bytes) { char[] str = new char[bytes.length << 1]; for (int i = 0, j = 0; i < bytes.length; i++) { str[j++] = HEX[(bytes[i] & 0xf0) >>> 4]; str[j++] = HEX[bytes[i] & 0x0f]; }/* www .jav a 2 s .c o m*/ return new String(str); } }