Here you can find the source of toHexString(byte[] in)
public static String toHexString(byte[] in)
//package com.java2s; public class Main { public static String toHexString(byte[] in) { byte ch = 0x00; int i = 0; if (in == null || in.length <= 0) return null; String pseudo[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F" }; StringBuffer out = new StringBuffer(in.length * 2); while (i < in.length) { ch = (byte) (in[i] & 0xF0); ch = (byte) (ch >>> 4); ch = (byte) (ch & 0x0F); out.append(pseudo[(int) ch]); ch = (byte) (in[i] & 0x0F); out.append(pseudo[(int) ch]); i++;//from w w w.j av a 2 s. c o m } String rslt = new String(out); return rslt; } }