Java tutorial
//package com.java2s; public class Main { public static String toHexString(byte[] b) { StringBuffer buffer = new StringBuffer(); if (b != null) for (int i = 0; i < b.length; ++i) { String s = Integer.toHexString(b[i] & 0xFF); if (s.length() == 1) { s = "0" + s; } buffer.append(s + " "); } return buffer.toString(); } }