java.lang.Object
org.codelibs.jcifs.smb.util.Hexdump
Utility class for hexadecimal dumping of binary data.
This class provides methods for converting binary data to readable hex format.
-
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 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[] data) Converts a byte array to a hexadecimal string representation.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
-
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 bytes to convert from the source array- Returns:
- a hexadecimal string representation of the byte array
-
toHexString
Converts a byte array to a hexadecimal string representation.- Parameters:
data- the byte array to convert- Returns:
- a hexadecimal string representation of the entire 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)
-