Java tutorial
//package com.java2s; public class Main { public static String toString(byte[] theByteArray) { StringBuffer out = new StringBuffer(); for (int i = 0; i < theByteArray.length; i++) { String s = Integer.toHexString(theByteArray[i] & 0xff); if (s.length() < 2) { out.append('0'); } out.append(s).append(' '); } return out.toString(); } }