Here you can find the source of toHex(byte data[])
public static final String toHex(byte data[])
//package com.java2s; //License from project: Open Source License public class Main { public static final String toHex(byte data[]) { char[] hex = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', }; StringBuffer result = new StringBuffer(data.length * 2); for (int i = 0; i < data.length; i++) { result.append(hex[(data[i] >> 4) & 0x0f]).append(hex[data[i] & 0x0f]); }/*from w w w . ja va2 s . c o m*/ return result.toString(); } }