/** * Return a hex-dump formatted version of a byte array. */ public static String hexDump(byte[] data) { StringBuffer result = new StringBuffer(); StringBuffer line; int pos = 0; int max = data.length; if (data.length == 0) return ""; while (pos < max) { int lineMax = Math.min(max-pos, 16); line = new StringBuffer(); // Left half of the hex dump (binary digits) for (int i=0; i 127)) c = '.'; line.append(c); } line.append('\n'); result.append(line); pos += 16; } return result.toString(); }