Here you can find the source of byteToHexString(byte[] b)
public static String byteToHexString(byte[] b)
//package com.java2s; //License from project: Apache License public class Main { private final static byte[] hex = "0123456789ABCDEF".getBytes(); public static String byteToHexString(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]; }//from w w w . j av a 2s. c o m return new String(buff); } }