Package eu.ill.webx.utils
Class HexString
java.lang.Object
eu.ill.webx.utils.HexString
Utility class to convert binary bytearrays into hexadecimal strings and vice versa.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringfromByteArray(byte[] data) Converts byte data to hex stringstatic StringfromByteArray(byte[] data, int length) Converts byte data to hex string using a maximum length of the datastatic byte[]toByteArray(String hexString, int expectedBytesLength) Converts from a hexadecimal string to a byte array.static StringtoDebugString(byte[] data) Converts byte data to a hex string using full length of byte data.static StringtoDebugString(byte[] data, int length) Converts byte data to hex string using a fixed maximum length of data The data is formatted for easier debugging.
-
Constructor Details
-
HexString
public HexString()Default constructor
-
-
Method Details
-
toDebugString
Converts byte data to a hex string using full length of byte data. The data is formatted for easier debugging.- Parameters:
data- the input binary data- Returns:
- hexadecimal representation of the data
-
toDebugString
Converts byte data to hex string using a fixed maximum length of data The data is formatted for easier debugging.- Parameters:
data- the input binary datalength- The maximum length of the string- Returns:
- hexadecimal representation of the data
-
fromByteArray
Converts byte data to hex string- Parameters:
data- the input binary data- Returns:
- hexadecimal representation of the data
-
fromByteArray
Converts byte data to hex string using a maximum length of the data- Parameters:
data- the input binary datalength- The maximum length of the string- Returns:
- hexadecimal representation of the data
-
toByteArray
Converts from a hexadecimal string to a byte array. Validation is made of the expected byte length.- Parameters:
hexString- the input hex stringexpectedBytesLength- the expected number of bytes- Returns:
- the byte array equivalent to the hex string
-