Here you can find the source of toHexString(byte[] bytes)
public static String toHexString(byte[] bytes)
//package com.java2s; //License from project: Open Source License public class Main { public static String toHexString(byte[] bytes) { String string = ""; for (int i = 0; i < bytes.length; i++) { if ((0xff & bytes[i]) < 0x10) { string += "0" + Integer.toHexString((0xFF & bytes[i])); } else { string += Integer.toHexString(0xFF & bytes[i]); }/* w w w .j a va 2s. c o m*/ } return string; } }