public class HexDump extends Object
Output look similar to the following example:
0000 : BF A4 3B 16 1C 88 5C 56 11 78 41 62 72 61 63 61 |..;...\V.xAbraca| 0016 : 64 61 62 72 61 1A 06 94 80 CA 1A 38 42 ED 58 25 |dabra......8B.X%| 0032 : 92 03 AD BF 7F 60 F4 73 AD 55 B0 A9 5C C4 86 B4 |.....`.s.U..\...| 0048 : 5B 11 62 55 B3 BD C4 EA C3 EA 4D 66 2A 02 1C 6C |[.bU......Mf*..l| 0064 : 0E 84 B1 F8 D8 05 91 51 CE A3 9E 46 |.......Q...F |The output can optionally be prefixed with space indention.
There are 3 sections in the output:
Parameters explanation:
bytesPerLine. The number of bytes represented on each line
of output. Typical values are 10 (produces output 50 characters wide
less indention) and 16 (produces output 74 characters wide
less indention). The example above use 16.indent. Number of space characters to prefix each line with.
Indention is typically preferable in logging scenario because it allows a log file consumer
to realize that the lines belong together a single log event.| Modifier and Type | Method and Description |
|---|---|
static String[] |
prettyPrint(byte[] input)
Dump hex output and return result as a String array where each string represents
a line of output.
|
static String[] |
prettyPrint(byte[] input,
Hex.HexCase caseType,
int bytesPerLine,
int indent)
Dump hex output and return result as a String array where each string represents
a line of output.
|
static void |
prettyPrint(byte[] input,
Hex.HexCase caseType,
int bytesPerLine,
int indent,
PrintStream ps)
Dump hex output and output into a PrintStream.
|
static void |
prettyPrint(byte[] input,
PrintStream ps)
Dump hex output and output into a PrintStream.
|
static String |
prettyPrintStr(byte[] input)
Dump hex output and return result as a String.
|
static String |
prettyPrintStr(byte[] input,
Hex.HexCase caseType,
int bytesPerLine,
int indent)
Dump hex output and return result as a String.
|
static String |
prettyPrintStr(byte[] input,
Hex.HexCase caseType,
int bytesPerLine,
int indent,
String lineSeparator)
Dump hex output and return result as a String.
|
public static void prettyPrint(byte[] input,
Hex.HexCase caseType,
int bytesPerLine,
int indent,
PrintStream ps)
System.out.input - input bytes to be pretty printedcaseType - if the hexadecimal representation should be in upper or lower casebytesPerLine - number of bytes to dump on each line of output (typically 10 or 16)indent - number of space characters to prefix each line of output withps - where the output goes topublic static void prettyPrint(byte[] input,
PrintStream ps)
System.out.
This method use recommended defaults:
caseType = UPPERbytesPerLine = 16indent = 4input - input bytes to be pretty printedps - where the output goes toprettyPrint(byte[], net.lbruun.hexutils.Hex.HexCase, int, int, java.io.PrintStream)public static String[] prettyPrint(byte[] input, Hex.HexCase caseType, int bytesPerLine, int indent)
input - input bytes to be pretty printedcaseType - if the hexadecimal representation should be in upper or lower casebytesPerLine - number of bytes to dump on each line of output (typically 10 or 16)indent - number of space characters to prefix each line of output withpublic static String[] prettyPrint(byte[] input)
This method use recommended defaults:
caseType = UPPERbytesPerLine = 16indent = 4input - input bytes to be pretty printedpublic static String prettyPrintStr(byte[] input, Hex.HexCase caseType, int bytesPerLine, int indent, String lineSeparator)
input - input bytes to be pretty printedcaseType - if the hexadecimal representation should be in upper or lower casebytesPerLine - number of bytes to dump on each line of output (typically 10 or 16)indent - number of space characters to prefix each line of output withlineSeparator - the string to use to separate linesprettyPrintStr(byte[], net.lbruun.hexutils.Hex.HexCase, int, int)public static String prettyPrintStr(byte[] input, Hex.HexCase caseType, int bytesPerLine, int indent)
System.lineSeparator()
is used to as line separator.input - input bytes to be pretty printedcaseType - if the hexadecimal representation should be in upper or lower casebytesPerLine - number of bytes to dump on each line of output (typically 10 or 16)indent - number of space characters to prefix each line of output withprettyPrintStr(byte[], net.lbruun.hexutils.Hex.HexCase, int, int)public static String prettyPrintStr(byte[] input)
System.lineSeparator()
is used as line separator.
This method use recommended defaults:
caseType = UPPERbytesPerLine = 16indent = 4lineSeparator = System.lineSeparator()input - input bytes to be pretty printedprettyPrintStr(byte[], net.lbruun.hexutils.Hex.HexCase, int, int)Copyright © 2022 lbruun.net. All rights reserved.