Package org.openhab.core.util
Class HexUtils
java.lang.Object
org.openhab.core.util.HexUtils
Static utility methods that are helpful when dealing with hex data and byte arrays.
- Author:
- Kai Kreuzer - Initial contribution, Martin van Wingerden - Implemented the reverse operation
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
bytesToHex
(byte[] bytes) Converts a byte array into a hex string (in format "0123456789ABCDEF").static String
bytesToHex
(byte[] bytes, @Nullable CharSequence delimiter) Converts a byte array into a hex string with a given delimiter.static byte[]
byteToHex
(byte value) static byte
hexToByte
(byte high, byte low) static byte[]
hexToBytes
(String hexString) Converts an hex string (in format "0123456789ABCDEF") into a byte arraystatic byte[]
hexToBytes
(String hexString, String delimiter) Converts an hex string (eg.
-
Method Details
-
bytesToHex
Converts a byte array into a hex string with a given delimiter. Example: Delimiter "-" results in Strings like "01-23-45".- Parameters:
bytes
- the byte arraydelimiter
- a delimiter that is placed between every two bytes- Returns:
- the corresponding hex string
-
bytesToHex
Converts a byte array into a hex string (in format "0123456789ABCDEF").- Parameters:
bytes
- the byte array- Returns:
- the corresponding hex string
-
byteToHex
public static byte[] byteToHex(byte value) -
hexToBytes
Converts an hex string (eg. format "01-23-45") into a byte array- Parameters:
hexString
- the hex stringdelimiter
- a delimiter that was placed between every two bytes- Returns:
- the corresponding byte array
-
hexToBytes
Converts an hex string (in format "0123456789ABCDEF") into a byte array- Parameters:
hexString
- the hex string- Returns:
- the corresponding byte array
-
hexToByte
public static byte hexToByte(byte high, byte low)
-