Here you can find the source of bytesToHexString(byte[] bytes)
private static String bytesToHexString(byte[] bytes)
//package com.java2s; public class Main { private static String bytesToHexString(byte[] bytes) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < bytes.length; i++) { String hex = Integer.toHexString(0xFF & bytes[i]); if (hex.length() == 1) { sb.append('0'); }//from w w w .ja v a 2 s . c om sb.append(hex); } return sb.toString(); } }