Here you can find the source of bin2Hex(byte[] b)
public final static String bin2Hex(byte[] b)
//package com.java2s; public class Main { private static final char HEX_DIGITS[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; public final static String bin2Hex(byte[] b) { return bin2Hex(b, 0, b.length); }/*from ww w . j a v a 2 s .c om*/ public final static String bin2Hex(byte[] b, int pos, int length) { if (length < 0 || length > b.length || pos + length > b.length) throw new ArrayIndexOutOfBoundsException(); StringBuilder sb = new StringBuilder(length * 2); for (int i = pos, size = pos + length; i < size; i++) { sb.append(HEX_DIGITS[(b[i] & 0xf0) >>> 4]); sb.append(HEX_DIGITS[b[i] & 0x0f]); } return sb.toString(); } }