Java tutorial
//package com.java2s; public class Main { public static String bytesToHex(byte[] data) { if (data == null) { return null; } int len = data.length; String str = ""; for (int i = 0; i < len; i++) { if ((data[i] & 0xFF) < 16) str = str + "0" + Integer.toHexString(data[i] & 0xFF); else str = str + Integer.toHexString(data[i] & 0xFF); } return str; } }