Here you can find the source of toHexString(byte b)
public static String toHexString(byte b)
//package com.java2s; //License from project: Apache License public class Main { public static String toHexString(byte b) { String s = Integer.toHexString(b & 0xFF).toUpperCase(); return (s.length() == 2) ? (s) : ("0" + s); }//from www . j av a 2 s . c o m public static String toHexString(byte[] b) { return toHexString(b, " "); } public static String toHexString(byte[] b, String glue) { String s = ""; if (null != b && null != glue) { for (int i = 0; i < b.length; i++) { s += (i == 0 ? "" : glue) + toHexString(b[i]); } } return s; } }