Here you can find the source of binToHexString(byte[] bytes)
public static String binToHexString(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 String binToHexString(byte[] bytes) { return new String(binToHex(bytes)); }/*from www. j av a 2s. com*/ public static String binToHexString(byte[] bytes, int offset, int len) { return new String(binToHex(bytes, offset, len)); } public static char[] binToHex(byte[] bytes) { return binToHex(bytes, 0, bytes.length); } 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; } }