Here you can find the source of bytes2hex(byte[] bts)
public static String bytes2hex(byte[] bts)
//package com.java2s; //License from project: Apache License public class Main { public static String bytes2hex(byte[] bts) { char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; int j = bts.length; char str[] = new char[j * 2]; int k = 0; for (int i = 0; i < j; i++) { byte byte0 = bts[i]; str[k++] = hexDigits[byte0 >>> 4 & 0xf]; str[k++] = hexDigits[byte0 & 0xf]; }/* w w w . j a v a2s. c om*/ return new String(str); } }