org.apache.poi.util
Class HexDump
- java.lang.Object
-
- org.apache.poi.util.HexDump
-
public class HexDump extends java.lang.Objectdump data in hexadecimal format; derived from a HexDump utility I wrote in June 2001.
-
-
Field Summary
Fields Modifier and Type Field and Description static java.lang.StringEOL
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static char[]byteToHex(int value)static java.lang.Stringdump(byte[] data, long offset, int index)dump an array of bytes to a Stringstatic voiddump(byte[] data, long offset, java.io.OutputStream stream, int index)dump an array of bytes to an OutputStreamstatic voiddump(byte[] data, long offset, java.io.OutputStream stream, int index, int length)dump an array of bytes to an OutputStreamstatic voiddump(java.io.InputStream in, java.io.PrintStream out, int start, int bytesToDump)DumpsbytesToDumpbytes to an output stream.static char[]intToHex(int value)static char[]longToHex(long value)static voidmain(java.lang.String[] args)static char[]shortToHex(int value)static java.lang.StringtoHex(byte value)Converts the parameter to a hex value.static java.lang.StringtoHex(byte[] value)Converts the parameter to a hex value.static java.lang.StringtoHex(byte[] value, int bytesPerLine)Converts the parameter to a hex value breaking the results into lines.static java.lang.StringtoHex(int value)Converts the parameter to a hex value.static java.lang.StringtoHex(long value)Converts the parameter to a hex value.static java.lang.StringtoHex(short value)Converts the parameter to a hex value.static java.lang.StringtoHex(short[] value)Converts the parameter to a hex value.
-
-
-
Method Detail
-
dump
public static void dump(byte[] data, long offset, java.io.OutputStream stream, int index, int length) throws java.io.IOException, java.lang.ArrayIndexOutOfBoundsException, java.lang.IllegalArgumentExceptiondump an array of bytes to an OutputStream- Parameters:
data- the byte array to be dumpedoffset- its offset, whatever that might meanstream- the OutputStream to which the data is to be writtenindex- initial index into the byte arraylength- number of characters to output- Throws:
java.io.IOException- is thrown if anything goes wrong writing the data to streamjava.lang.ArrayIndexOutOfBoundsException- if the index is outside the data array's boundsjava.lang.IllegalArgumentException- if the output stream is null
-
dump
public static void dump(byte[] data, long offset, java.io.OutputStream stream, int index) throws java.io.IOException, java.lang.ArrayIndexOutOfBoundsException, java.lang.IllegalArgumentExceptiondump an array of bytes to an OutputStream- Parameters:
data- the byte array to be dumpedoffset- its offset, whatever that might meanstream- the OutputStream to which the data is to be writtenindex- initial index into the byte array- Throws:
java.io.IOException- is thrown if anything goes wrong writing the data to streamjava.lang.ArrayIndexOutOfBoundsException- if the index is outside the data array's boundsjava.lang.IllegalArgumentException- if the output stream is null
-
dump
public static java.lang.String dump(byte[] data, long offset, int index)dump an array of bytes to a String- Parameters:
data- the byte array to be dumpedoffset- its offset, whatever that might meanindex- initial index into the byte array- Returns:
- output string
- Throws:
java.lang.ArrayIndexOutOfBoundsException- if the index is outside the data array's bounds
-
toHex
public static java.lang.String toHex(byte[] value)
Converts the parameter to a hex value.- Parameters:
value- The value to convert- Returns:
- A String representing the array of bytes
-
toHex
public static java.lang.String toHex(short[] value)
Converts the parameter to a hex value.- Parameters:
value- The value to convert- Returns:
- A String representing the array of shorts
-
toHex
public static java.lang.String toHex(byte[] value, int bytesPerLine)Converts the parameter to a hex value breaking the results into lines.
- Parameters:
value- The value to convertbytesPerLine- The maximum number of bytes per line. The next byte will be written to a new line- Returns:
- A String representing the array of bytes
-
toHex
public static java.lang.String toHex(short value)
Converts the parameter to a hex value.- Parameters:
value- The value to convert- Returns:
- The result right padded with 0
-
toHex
public static java.lang.String toHex(byte value)
Converts the parameter to a hex value.- Parameters:
value- The value to convert- Returns:
- The result right padded with 0
-
toHex
public static java.lang.String toHex(int value)
Converts the parameter to a hex value.- Parameters:
value- The value to convert- Returns:
- The result right padded with 0
-
toHex
public static java.lang.String toHex(long value)
Converts the parameter to a hex value.- Parameters:
value- The value to convert- Returns:
- The result right padded with 0
-
dump
public static void dump(java.io.InputStream in, java.io.PrintStream out, int start, int bytesToDump) throws java.io.IOExceptionDumpsbytesToDumpbytes to an output stream.- Parameters:
in- The stream to read fromout- The output streamstart- The index to use as the starting position for the left hand side labelbytesToDump- The number of bytes to output. Use -1 to read until the end of file.- Throws:
java.io.IOException
-
longToHex
public static char[] longToHex(long value)
- Returns:
- char array of 4 (zero padded) uppercase hex chars and prefixed with '0x'
-
intToHex
public static char[] intToHex(int value)
- Returns:
- char array of 4 (zero padded) uppercase hex chars and prefixed with '0x'
-
shortToHex
public static char[] shortToHex(int value)
- Returns:
- char array of 2 (zero padded) uppercase hex chars and prefixed with '0x'
-
byteToHex
public static char[] byteToHex(int value)
- Returns:
- char array of 1 (zero padded) uppercase hex chars and prefixed with '0x'
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception- Throws:
java.lang.Exception
-
-
DataMelt 3.0 © DataMelt by jWork.ORG