Here you can find the source of toHex(byte[] b)
public static String toHex(byte[] b)
//package com.java2s; import java.util.Formatter; import java.util.Locale; public class Main { public static String toHex(byte[] b) { StringBuilder sb = new StringBuilder(); Formatter fmt = new Formatter(sb, Locale.US); for (int i = 0; i < b.length; ++i) { fmt.format("%02X", b[i]); }// ww w . j av a 2 s. c o m return fmt.toString(); } }