java.lang.Object
org.codelibs.jcifs.smb1.util.Hexdump
Utility class for hexadecimal dump operations.
This class provides methods to convert binary data to
hexadecimal string representation for debugging purposes.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final char[]Array of hexadecimal digit characters used for converting binary data to hex representation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidhexdump(PrintStream ps, byte[] src, int srcIndex, int length) Generate "hexdump" output of the buffer at src like the following:static voidtoHexChars(int val, char[] dst, int dstIndex, int size) This is the same astoHexString(int val, int size)but provides a more practical form when trying to avoidStringconcatenation andStringBuffer.static voidtoHexChars(long val, char[] dst, int dstIndex, int size) Converts a long value to hexadecimal characters and writes them to the specified character array.static StringtoHexString(byte[] src, int srcIndex, int size) Converts a byte array to a hexadecimal string representation.static StringtoHexString(int val, int size) This is an alternative to thejava.lang.Integer.toHexStringmethod.static StringtoHexString(long val, int size) Converts a long value to a hexadecimal string representation with specified padding.
-
Field Details
-
HEX_DIGITS
public static final char[] HEX_DIGITSArray of hexadecimal digit characters used for converting binary data to hex representation.
-
-
Constructor Details
-
Hexdump
public Hexdump()Default constructor.
-
-
Method Details
-
hexdump
Generate "hexdump" output of the buffer at src like the following:00000: 04 d2 29 00 00 01 00 00 00 00 00 01 20 45 47 46 |..)......... EGF| 00010: 43 45 46 45 45 43 41 43 41 43 41 43 41 43 41 43 |CEFEECACACACACAC| 00020: 41 43 41 43 41 43 41 43 41 43 41 41 44 00 00 20 |ACACACACACAAD.. | 00030: 00 01 c0 0c 00 20 00 01 00 00 00 00 00 06 20 00 |..... ........ .| 00040: ac 22 22 e1 |."". |
- Parameters:
ps- the PrintStream to write the hexdump output tosrc- the source byte array containing the data to dumpsrcIndex- the starting index in the source arraylength- the number of bytes to dump from the source array
-
toHexString
This is an alternative to thejava.lang.Integer.toHexStringmethod. It is an efficient relative that also will pad the left side so that the result issizedigits.- Parameters:
val- the integer value to convert to hexadecimalsize- the desired length of the resulting hex string (will be left-padded with zeros)- Returns:
- a hexadecimal string representation of the value, padded to the specified size
-
toHexString
Converts a long value to a hexadecimal string representation with specified padding.- Parameters:
val- the long value to convert to hexadecimalsize- the desired length of the resulting hex string (will be left-padded with zeros)- Returns:
- a hexadecimal string representation of the value, padded to the specified size
-
toHexString
Converts a byte array to a hexadecimal string representation.- Parameters:
src- the source byte array to convertsrcIndex- the starting index in the source arraysize- the number of characters in the resulting hex string- Returns:
- a hexadecimal string representation of the byte array
-
toHexChars
public static void toHexChars(int val, char[] dst, int dstIndex, int size) This is the same astoHexString(int val, int size)but provides a more practical form when trying to avoidStringconcatenation andStringBuffer.- Parameters:
val- the integer value to convert to hexadecimal charactersdst- the destination character array to write the hex digits intodstIndex- the starting index in the destination arraysize- the number of hex digits to write (will be left-padded with zeros)
-
toHexChars
public static void toHexChars(long val, char[] dst, int dstIndex, int size) Converts a long value to hexadecimal characters and writes them to the specified character array.- Parameters:
val- the long value to convert to hexadecimal charactersdst- the destination character array to write the hex digits intodstIndex- the starting index in the destination arraysize- the number of hex digits to write (will be left-padded with zeros)
-