Java tutorial
//package com.java2s; public class Main { public static String tohex(byte[] buffer) { StringBuilder result = new StringBuilder(); for (int i = 0; i < buffer.length; ++i) result.append(hexToAscii((buffer[i] >>> 4) & 0xF)).append(hexToAscii(buffer[i] & 0x0F)); return result.toString(); } private static final char hexToAscii(int h) { if ((h >= 10) && (h <= 15)) return (char) ('A' + (h - 10)); if ((h >= 0) && (h <= 9)) return (char) ('0' + h); return '0'; } }