Here you can find the source of byteToHex(byte b)
public static String byteToHex(byte b)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from ww w.ja va 2 s . c o m*/ * Converts the given byte to a hex String. */ public static String byteToHex(byte b) { String hex = Integer.toHexString(b); if (hex.length() >= 2) { return hex.substring(hex.length() - 2); } return String.format("0%s", hex); } }