Java tutorial
//package com.java2s; public class Main { public static String HexEncode(byte[] toencode) { StringBuilder sb = new StringBuilder(toencode.length * 2); for (byte b : toencode) { sb.append(Integer.toHexString((b & 0xf0) >>> 4)); sb.append(Integer.toHexString(b & 0x0f)); } return sb.toString(); } }