Package org.apache.commons.io
Class HexDump
java.lang.Object
org.apache.commons.io.HexDump
Dumps data in hexadecimal format.
Provides a single function to take an array of bytes and display it in hexadecimal form.
Origin of code: POI.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
dump
(byte[] data, long offset, OutputStream stream, int index) Dump an array of bytes to an OutputStream.private static StringBuilder
dump
(StringBuilder _cbuffer, byte value) Dump a byte value into a StringBuilder.private static StringBuilder
dump
(StringBuilder _lbuffer, long value) Dump a long value into a StringBuilder.
-
Field Details
-
EOL
The line-separator (initializes to "line.separator" system property. -
_hexcodes
private static final char[] _hexcodes -
_shifts
private static final int[] _shifts
-
-
Constructor Details
-
HexDump
public HexDump()Instances should NOT be constructed in standard programming.
-
-
Method Details
-
dump
public static void dump(byte[] data, long offset, OutputStream stream, int index) throws IOException, ArrayIndexOutOfBoundsException, IllegalArgumentException Dump an array of bytes to an OutputStream. The output is formatted for human inspection, with a hexadecimal offset followed by the hexadecimal values of the next 16 bytes of data and the printable ASCII characters (if any) that those bytes represent printed per each line of output.The offset argument specifies the start offset of the data array within a larger entity like a file or an incoming stream. For example, if the data array contains the third kibibyte of a file, then the offset argument should be set to 2048. The offset value printed at the beginning of each line indicates where in that larger entity the first byte on that line is located.
All bytes between the given index (inclusive) and the end of the data array are dumped.
- Parameters:
data
- the byte array to be dumpedoffset
- offset of the byte array within a larger entitystream
- the OutputStream to which the data is to be writtenindex
- initial index into the byte array- Throws:
IOException
- is thrown if anything goes wrong writing the data to streamArrayIndexOutOfBoundsException
- if the index is outside the data array's boundsIllegalArgumentException
- if the output stream is null
-
dump
Dump a long value into a StringBuilder.- Parameters:
_lbuffer
- the StringBuilder to dump the value invalue
- the long value to be dumped- Returns:
- StringBuilder containing the dumped value.
-
dump
Dump a byte value into a StringBuilder.- Parameters:
_cbuffer
- the StringBuilder to dump the value invalue
- the byte value to be dumped- Returns:
- StringBuilder containing the dumped value.
-