Here you can find the source of toHex(byte b)
public static String toHex(byte b)
//package com.java2s; public class Main { public static String toHex(byte b) { char[] buf = new char[2]; for (int i = 0; i < 2; i++) { // buf[1 - i] = digits[b & 0xF]; b = (byte) (b >>> 4); }/*from w w w . j a v a 2s . c o m*/ return new String(buf); } }