Here you can find the source of bytesToHexString(byte[] bytes)
public static String bytesToHexString(byte[] bytes)
//package com.java2s; public class Main { public static String bytesToHexString(byte[] bytes) { // http://stackoverflow.com/questions/332079 StringBuffer sb = new StringBuffer(); for (int i = 0; i < bytes.length; i++) { String hex = Integer.toHexString(0xFF & bytes[i]); if (hex.length() == 1) { sb.append('0'); }/*from ww w .ja va 2 s . co m*/ sb.append(hex); } return sb.toString(); } }