Here you can find the source of bytesToHexString(byte[] bs)
public static String bytesToHexString(byte[] bs)
//package com.java2s; //License from project: Apache License public class Main { private static final char[] hex = "0123456789ABCDEF".toCharArray(); public static String bytesToHexString(byte[] bs) { if (bs == null || bs.length == 0) { return ""; }//from w w w. j a v a 2 s . co m StringBuffer str = new StringBuffer(bs.length * 4); for (int i = 0; i < bs.length; i++) { str.append(hex[(bs[i] >> 4) & 0x0f]); str.append(hex[bs[i] & 0x0f]); } return str.toString(); } }