Here you can find the source of bytesToHexString(byte[] src)
public static String bytesToHexString(byte[] src)
//package com.java2s; //License from project: Open Source License public class Main { public static String bytesToHexString(byte[] src) { if (src == null || src.length <= 0) { return ""; }//from w w w. ja v a 2 s . c om StringBuilder stringBuilder = new StringBuilder(""); for (int i = 0; i < src.length; i++) { String hv = Integer.toHexString(src[i] & 0xFF); if (hv.length() < 2) { stringBuilder.append(0); } stringBuilder.append(hv); } return stringBuilder.toString(); } }