Here you can find the source of bytes2HexString(byte[] b)
static String bytes2HexString(byte[] b)
//package com.java2s; //License from project: Apache License public class Main { static final char[] HEX_CHARS = "0123456789abcdef".toCharArray(); static String bytes2HexString(byte[] b) { StringBuilder sb = new StringBuilder(b.length << 2); for (byte x : b) { int hi = (x & 0xf0) >> 4; int lo = x & 0x0f; sb.append(HEX_CHARS[hi]);// w w w. ja v a 2 s. co m sb.append(HEX_CHARS[lo]); } return sb.toString(); } }