Here you can find the source of bytesToHex(byte[] bytes)
private static String bytesToHex(byte[] bytes)
//package com.java2s; public class Main { private final static char[] hexDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; private static String bytesToHex(byte[] bytes) { StringBuilder sb = new StringBuilder(); int t;/*from w w w .j ava 2s . c o m*/ for (int i = 0; i < 16; i++) { t = bytes[i]; if (t < 0) { t += 256; } sb.append(hexDigits[(t >>> 4)]); sb.append(hexDigits[(t % 16)]); } return sb.toString(); } }