Java tutorial
//package com.java2s; public class Main { private static final boolean DEBUG_FLG = false; public static String makeHexTextD(byte[] data) { if (DEBUG_FLG) { return makeHexText(data); } return ""; } public static String makeHexText(byte[] data) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < data.length; i++) { if (i != 0) { sb.append("-"); } sb.append(String.format("%02X", data[i])); } return sb.toString(); } }