Here you can find the source of convertToHex(byte[] in)
private static String convertToHex(byte[] in)
//package com.java2s; import java.util.Formatter; public class Main { private static String convertToHex(byte[] in) { StringBuilder builder = new StringBuilder(in.length * 2); Formatter formatter = new Formatter(builder); for (byte inByte : in) formatter.format("%02x", inByte); formatter.close();/*from w w w. ja va2s . c om*/ return formatter.toString(); } }