Here you can find the source of byteToHex(byte data)
public static String byteToHex(byte data)
//package com.java2s; //License from project: Open Source License public class Main { public static String byteToHex(byte data) { StringBuffer buf = new StringBuffer(); buf.append(toHexChar((data >>> 4) & 0x0F)); buf.append(toHexChar(data & 0x0F)); return buf.toString(); }//from w w w.ja v a 2 s .c o m public static char toHexChar(int i) { if ((0 <= i) && (i <= 9)) { return (char) ('0' + i); } else { return (char) ('a' + (i - 10)); } } }