Java tutorial
//package com.java2s; public class Main { private final static String HEX = "0123456789ABCDEF"; private static void appendHex(StringBuffer result, byte b) { result.append(HEX.charAt((b >> 4) & 0x0f)).append(HEX.charAt(b & 0x0f)); } }