Here you can find the source of toHex(byte[] data)
public static String toHex(byte[] data)
//package com.java2s; //License from project: Open Source License public class Main { protected static final char[] hexDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; public static String toHex(byte[] data) { char[] str = new char[data.length + data.length]; for (int i = data.length - 1, strIndex = str.length - 1; i >= 0; i--) { byte byte4i = data[i]; str[strIndex--] = hexDigits[byte4i & 0xF]; str[strIndex--] = hexDigits[byte4i >>> 4 & 0xF]; }/*ww w .j av a 2s. c o m*/ return new String(str); } }