org.apache.commons.io

Class HexDump

public class HexDump extends Object

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.

Version: $Id: HexDump.java 596667 2007-11-20 13:50:14Z niallp $

Author: Scott Sanders Marc Johnson

Field Summary
static StringEOL
The line-separator (initializes to "line.separator" system property.
static char[]_hexcodes
static int[]_shifts
Constructor Summary
HexDump()
Instances should NOT be constructed in standard programming.
Method Summary
static voiddump(byte[] data, long offset, OutputStream stream, int index)
Dump an array of bytes to an OutputStream.
static StringBufferdump(StringBuffer _lbuffer, long value)
Dump a long value into a StringBuffer.
static StringBufferdump(StringBuffer _cbuffer, byte value)
Dump a byte value into a StringBuffer.

Field Detail

EOL

public static final String EOL
The line-separator (initializes to "line.separator" system property.

_hexcodes

private static final char[] _hexcodes

_shifts

private static final int[] _shifts

Constructor Detail

HexDump

public HexDump()
Instances should NOT be constructed in standard programming.

Method Detail

dump

public static void dump(byte[] data, long offset, OutputStream stream, int index)
Dump an array of bytes to an OutputStream.

Parameters: data the byte array to be dumped offset its offset, whatever that might mean stream the OutputStream to which the data is to be written index initial index into the byte array

Throws: IOException is thrown if anything goes wrong writing the data to stream ArrayIndexOutOfBoundsException if the index is outside the data array's bounds IllegalArgumentException if the output stream is null

dump

private static StringBuffer dump(StringBuffer _lbuffer, long value)
Dump a long value into a StringBuffer.

Parameters: _lbuffer the StringBuffer to dump the value in value the long value to be dumped

Returns: StringBuffer containing the dumped value.

dump

private static StringBuffer dump(StringBuffer _cbuffer, byte value)
Dump a byte value into a StringBuffer.

Parameters: _cbuffer the StringBuffer to dump the value in value the byte value to be dumped

Returns: StringBuffer containing the dumped value.

Copyright (c) 2002-2011 Apache Software Foundation