Here you can find the source of binToHex(byte[] bytes)
public static char[] binToHex(byte[] bytes)
//package com.java2s; //License from project: Apache License public class Main { private static final char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; public static char[] binToHex(byte[] bytes) { return binToHex(bytes, 0, bytes.length); }/*from ww w .j a v a 2 s . c o m*/ public static char[] binToHex(byte[] bytes, int offset, int len) { final char[] sb = new char[len * 2]; final int end = offset + len; int index = 0; final char[] hexs = hex; for (int i = offset; i < end; i++) { byte b = bytes[i]; sb[index++] = (hexs[((b >> 4) & 0xF)]); sb[index++] = hexs[((b) & 0xF)]; } return sb; } }