Here you can find the source of toHexStr(byte[] b)
public static String toHexStr(byte[] b)
//package com.java2s; //License from project: Apache License public class Main { public static String toHexStr(byte[] b) { StringBuffer buffer = new StringBuffer(); for (int i = 0; i < b.length; ++i) { buffer.append(toHexStr(b[i])); }//from w w w . j av a 2 s.co m return buffer.toString(); } public static String toHexStr(byte b) { String s = Integer.toHexString(b & 0xFF); if (s.length() == 1) { return "0" + s; } else { return s; } } }