Java tutorial
//package com.java2s; public class Main { private static String toHexString(byte[] b) { return toHexString(b, b.length); } private static String toHexString(byte[] b, int len) { StringBuilder s = new StringBuilder(); s.append("\""); for (int i = 0; i < len; i++) { if (i > 0) { s.append(" "); } s.append(String.format("%02x", b[i] & 0xFF)); } s.append("\""); return s.toString(); } }