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) { if (bytes == null) { return ""; }//www . j a v a 2 s .c om StringBuffer buff = new StringBuffer(); int len = bytes.length; for (int j = 0; j < len; j++) { if ((bytes[j] & 0xff) < 16) { buff.append('0'); } buff.append(Integer.toHexString(bytes[j] & 0xff)); } return buff.toString(); } }