Top Description Fields Constructors Methods
org.apache.poi.util

public final Class HexDump

extends Object
Class Inheritance
Annotations
@Internal
Imports
java.io.IOException, .OutputStream, .OutputStreamWriter, java.nio.charset.Charset, .StandardCharsets

dump data in hexadecimal format

Field Summary

Modifier and TypeField and Description
public static final String
public static final Charset

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

string of 2 (zero padded) uppercase hex chars and prefixed with '0x'
byteToHex
(int value)

public static void
dump(final byte[]
the byte array to be dumped
data
,
final long
its offset, whatever that might mean
offset
,
final OutputStream
the OutputStream to which the data is to be written
stream
,
final int
initial index into the byte array
index
,
final int
number of characters to output
length
)

dump an array of bytes to an OutputStream

public static synchronized void
dump(final byte[]
the byte array to be dumped
data
,
final long
its offset, whatever that might mean
offset
,
final OutputStream
the OutputStream to which the data is to be written
stream
,
final int
initial index into the byte array
index
)

dump an array of bytes to an OutputStream

public static String

Returns:

output string
dump
(final byte[]
the byte array to be dumped
data
,
final long
its offset, whatever that might mean
offset
,
final int
initial index into the byte array
index
)

dump an array of bytes to a String

public static String

Returns:

output string
dump
(final byte[]
the byte array to be dumped
data
,
final long
its offset, whatever that might mean
offset
,
final int
initial index into the byte array
index
,
final int
number of characters to output
length
)

dump an array of bytes to a String

public static String

Returns:

string of 8 (zero padded) uppercase hex chars and prefixed with '0x'
intToHex
(int value)

public static String

Returns:

string of 16 (zero padded) uppercase hex chars and prefixed with '0x'
longToHex
(long value)

public static String

Returns:

string of 4 (zero padded) uppercase hex chars and prefixed with '0x'
shortToHex
(int value)

public static char
toAscii(int dataB)

public static String

Returns:

A String representing the array of bytes
toHex
(final byte[]
The value to convert
value
)

Converts the parameter to a hex value.

public static String

Returns:

The result right padded with 0
toHex
(short
The value to convert
value
)

Converts the parameter to a hex value.

public static String

Returns:

The result right padded with 0
toHex
(byte
The value to convert
value
)

Converts the parameter to a hex value.

public static String

Returns:

The result right padded with 0
toHex
(int
The value to convert
value
)

Converts the parameter to a hex value.

public static String

Returns:

The result right padded with 0
toHex
(long
The value to convert
value
)

Converts the parameter to a hex value.

private static void
writeHex(StringBuilder sb, long value, int nDigits, String prefix)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

EOLback to summary
public static final String EOL
UTF8back to summary
public static final Charset UTF8

Constructor Detail

HexDumpback to summary
private HexDump()

Method Detail

byteToHexback to summary
public static String byteToHex(int value)
Returns:String

string of 2 (zero padded) uppercase hex chars and prefixed with '0x'

dumpback to summary
public static void dump(final byte[] data, final long offset, final OutputStream stream, final int index, final int length) throws IOException, ArrayIndexOutOfBoundsException, IllegalArgumentException

dump an array of bytes to an OutputStream

Parameters
data:byte[]

the byte array to be dumped

offset:long

its offset, whatever that might mean

stream:OutputStream

the OutputStream to which the data is to be written

index:int

initial index into the byte array

length:int

number of characters to output

Exceptions
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
dumpback to summary
public static synchronized void dump(final byte[] data, final long offset, final OutputStream stream, final int index) throws IOException, ArrayIndexOutOfBoundsException, IllegalArgumentException

dump an array of bytes to an OutputStream

Parameters
data:byte[]

the byte array to be dumped

offset:long

its offset, whatever that might mean

stream:OutputStream

the OutputStream to which the data is to be written

index:int

initial index into the byte array

Exceptions
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
dumpback to summary
public static String dump(final byte[] data, final long offset, final int index)

dump an array of bytes to a String

Parameters
data:byte[]

the byte array to be dumped

offset:long

its offset, whatever that might mean

index:int

initial index into the byte array

Returns:String

output string

Exceptions
ArrayIndexOutOfBoundsException:
if the index is outside the data array's bounds
dumpback to summary
public static String dump(final byte[] data, final long offset, final int index, final int length)

dump an array of bytes to a String

Parameters
data:byte[]

the byte array to be dumped

offset:long

its offset, whatever that might mean

index:int

initial index into the byte array

length:int

number of characters to output

Returns:String

output string

Exceptions
ArrayIndexOutOfBoundsException:
if the index is outside the data array's bounds
intToHexback to summary
public static String intToHex(int value)
Returns:String

string of 8 (zero padded) uppercase hex chars and prefixed with '0x'

longToHexback to summary
public static String longToHex(long value)
Returns:String

string of 16 (zero padded) uppercase hex chars and prefixed with '0x'

shortToHexback to summary
public static String shortToHex(int value)
Returns:String

string of 4 (zero padded) uppercase hex chars and prefixed with '0x'

toAsciiback to summary
public static char toAscii(int dataB)
toHexback to summary
public static String toHex(final byte[] value)

Converts the parameter to a hex value.

Parameters
value:byte[]

The value to convert

Returns:String

A String representing the array of bytes

toHexback to summary
public static String toHex(short value)

Converts the parameter to a hex value.

Parameters
value:short

The value to convert

Returns:String

The result right padded with 0

toHexback to summary
public static String toHex(byte value)

Converts the parameter to a hex value.

Parameters
value:byte

The value to convert

Returns:String

The result right padded with 0

toHexback to summary
public static String toHex(int value)

Converts the parameter to a hex value.

Parameters
value:int

The value to convert

Returns:String

The result right padded with 0

toHexback to summary
public static String toHex(long value)

Converts the parameter to a hex value.

Parameters
value:long

The value to convert

Returns:String

The result right padded with 0

writeHexback to summary
private static void writeHex(StringBuilder sb, long value, int nDigits, String prefix)
See Also
Integer#toHexString(int), Long#toHexString(long)