Here you can find the source of bytes2HexString(byte[] bytes)
public static String bytes2HexString(byte[] bytes)
//package com.java2s; //License from project: Apache License public class Main { private static final char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; public static String bytes2HexString(byte[] bytes) { if (bytes == null) return null; int len = bytes.length; if (len <= 0) return null; char[] ret = new char[len << 1]; for (int i = 0, j = 0; i < len; i++) { ret[j++] = hexDigits[bytes[i] >>> 4 & 0x0f]; ret[j++] = hexDigits[bytes[i] & 0x0f]; }/*from w w w . j a va2 s . c om*/ return new String(ret); } }