Java tutorial
//package com.java2s; public class Main { public static String getPrintBytes(String tag, byte[] bytes) { String resp = ""; for (int i = 0; i < bytes.length; i++) { resp += " " + Integer.toHexString(bytes[i]); } String msg = "Data:" + tag + " \t" + String.format("%03d", bytes.length) + ": " + resp; return msg; } }