Here you can find the source of toHex(byte[] b)
public static String toHex(byte[] b)
//package com.java2s; //License from project: Apache License public class Main { public static String toHex(byte[] b) { StringBuilder buffer = new StringBuilder(128); for (byte i : b) { buffer.append(toHex(i));/*from w w w .j a v a 2s . c o m*/ } return buffer.toString(); } public static char[] toHex(byte in) { char[] out = new char[2]; int h = 0; h = in >> 4 & 0xF; out[0] = (char) (h > 9 ? h + 0x37 : h + 0x30); h = in & 0xF; out[1] = (char) (h > 9 ? h + 0x37 : h + 0x30); return out; } }