Class HexFormatExamples
java.lang.Object
net.jrodolfo.java_evolution.java17.HexFormatExamples
Demonstrates
HexFormat, introduced in Java 17.
Before Java 17, converting bytes to hexadecimal text and parsing hexadecimal text back into bytes often required custom utility code or an external library.
HexFormat solves this small but common problem with a standard API
that supports parsing, formatting, delimiters, prefixes, and suffixes.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
HexFormatExamples
public HexFormatExamples()
-
-
Method Details
-
toHex
Converts bytes to lowercase hexadecimal text.- Parameters:
bytes- the bytes to format- Returns:
- hexadecimal text
-
fromHex
Parses hexadecimal text into bytes.- Parameters:
hex- hexadecimal text- Returns:
- parsed bytes
-
toColonDelimitedHex
Formats bytes with a delimiter.- Parameters:
bytes- the bytes to format- Returns:
- hexadecimal text separated with colons
-