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 (byte aByte : bytes) { String hex = Integer.toHexString(0xFF & aByte); if (hex.length() == 1) { sb.append('0'); }//from w ww .j a v a 2 s.c o m sb.append(hex); } return sb.toString(); } }