From 265b0aca555d9880361b754b6a18ce70b5be28cd Mon Sep 17 00:00:00 2001 From: mcentner Date: Wed, 16 Jun 2010 11:19:41 +0000 Subject: Refactored smart card unit tests to use Spring to configure smart card emulators. git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@754 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../main/java/at/gv/egiz/bku/utils/HexDump.java | 33 ++++++++++++++-------- 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'utils') diff --git a/utils/src/main/java/at/gv/egiz/bku/utils/HexDump.java b/utils/src/main/java/at/gv/egiz/bku/utils/HexDump.java index 88d49bad..a1b8a00d 100644 --- a/utils/src/main/java/at/gv/egiz/bku/utils/HexDump.java +++ b/utils/src/main/java/at/gv/egiz/bku/utils/HexDump.java @@ -32,14 +32,21 @@ public class HexDump { public static void hexDump(InputStream is, Writer writer) throws IOException { hexDump(is, writer, 16); } + + public static void hexDump(InputStream is, Writer writer, int chunkSize) throws IOException { + hexDump(is, writer, chunkSize, false); + } - public static void hexDump(InputStream is, Writer writer, int chunkSize) throws IOException { + public static void hexDump(InputStream is, Writer writer, int chunkSize, boolean plain) throws IOException { byte[] chunk = new byte[chunkSize]; long adr = 0; for (int l; (l = is.read(chunk)) != -1;) { + + if (!plain) { + writer.append(String.format("[%06x]", adr)); + } - writer.append(String.format("[%06x]", adr)); for (int i = 0; i < l; i++) { if (i % 8 == 0) { writer.append(" "); @@ -53,16 +60,18 @@ public class HexDump { for (int i = 0; i < (chunkSize - l); i++) { writer.append(" "); } - - for (int i = 0; i < l; i++) { - if (i % 8 == 0) { - writer.append(" "); - } - if (chunk[i] > 31 && chunk[i] < 127) { - writer.append((char) chunk[i]); - } else { - writer.append("."); - } + + if (!plain) { + for (int i = 0; i < l; i++) { + if (i % 8 == 0) { + writer.append(" "); + } + if (chunk[i] > 31 && chunk[i] < 127) { + writer.append((char) chunk[i]); + } else { + writer.append("."); + } + } } writer.append("\n"); -- cgit v1.2.3