Here you can find the source of toHexString(byte b)
public static String toHexString(byte b)
//package com.java2s; //License from project: Creative Commons License public class Main { protected static final char[] hexChars = "0123456789ABCDEF".toCharArray(); public static String toHexString(byte b) { return toHexString(new byte[] { b }); }/*w ww .j a v a 2 s . co m*/ public static String toHexString(byte[] bytes) { return toHexString(bytes, false); } public static String toHexString(byte[] bytes, boolean spaced) { StringBuilder sb = new StringBuilder(); for (byte b : bytes) { int temp = b & 0xFF; sb.append(hexChars[temp >>> 4]); sb.append(hexChars[temp & 0xF]); if (spaced) sb.append(' '); } return sb.toString(); } }