Here you can find the source of toHexString(byte b[])
public static String toHexString(byte b[])
//package com.java2s; //License from project: Open Source License public class Main { public static String toHexString(byte b[]) { StringBuffer hexString = new StringBuffer(); for (int i = 0; i < b.length; i++) { String plainText = Integer.toHexString(0xff & b[i]); if (plainText.length() < 2) plainText = "0" + plainText; hexString.append(plainText); }//from w ww . j ava 2 s. c om return hexString.toString(); } public static String toHexString(byte b) { String plainText = Integer.toHexString(0xff & b); if (plainText.length() < 2) plainText = "0" + plainText; return plainText; } }