Here you can find the source of bytes2HexString(byte[] bytes)
public static String bytes2HexString(byte[] bytes)
//package com.java2s; public class Main { public static String bytes2HexString(byte[] bytes) { if (bytes == null) return null; StringBuilder ret = new StringBuilder(2 * bytes.length); for (int i = 0; i < bytes.length; i++) { int b; b = 0x0f & (bytes[i] >> 4); ret.append("0123456789ABCDEF".charAt(b)); b = 0x0f & bytes[i];/*from w w w .j a va 2 s . c o m*/ ret.append("0123456789ABCDEF".charAt(b)); } return ret.toString(); } }