Here you can find the source of bytesToHex(byte[] data, char[] chars)
public static String bytesToHex(byte[] data, char[] chars)
//package com.java2s; //License from project: Apache License public class Main { public static String bytesToHex(byte[] data, char[] chars) { int length = data.length; char[] out = new char[length << 1]; for (int i = 0, j = 0; i < length; i++) { out[j++] = chars[(0xF0 & data[i]) >>> 4]; out[j++] = chars[0x0F & data[i]]; }/* w w w . ja va 2 s . c om*/ return new String(out); } }