Here you can find the source of Bytes2HexString(byte[] b)
public static String Bytes2HexString(byte[] b)
//package com.java2s; //License from project: Apache License public class Main { private final static byte[] hex = "0123456789ABCDEF".getBytes(); public static String Bytes2HexString(byte[] b) { byte[] buff = new byte[2 * b.length]; for (int i = 0; i < b.length; i++) { buff[2 * i] = hex[(b[i] >> 4) & 0x0f]; buff[2 * i + 1] = hex[b[i] & 0x0f]; }// w w w . j av a2 s . c o m return new String(buff); } }