Here you can find the source of bytesToHexString(byte[] bytes)
public static String bytesToHexString(byte[] bytes)
//package com.java2s; //License from project: Apache License public class Main { public 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 2s .c om*/ sb.append(hex); } return sb.toString(); } }