Here you can find the source of byteToString(StringBuilder sb, byte b)
static void byteToString(StringBuilder sb, byte b)
//package com.java2s; //License from project: Apache License public class Main { static void byteToString(StringBuilder sb, byte b) { int unsigned_byte = b < 0 ? b + 256 : b; int hi = unsigned_byte / 16; int lo = unsigned_byte % 16; sb.append("0123456789ABCDEF".substring(hi, hi + 1)); sb.append("0123456789ABCDEF".substring(lo, lo + 1)); }//from ww w . j a v a 2 s . co m }