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) { StringBuffer buf = new StringBuffer(bytes.length * 2); for (byte b : bytes) { String s = Integer.toString(0xFF & b, 16); if (s.length() < 2) buf.append('0'); buf.append(s);// w ww . java 2s . co m } return buf.toString(); } }