8251989: Unified Hex formatting and parsing utility

Roger Riggs Roger.Riggs at oracle.com
Mon Sep 28 15:32:37 UTC 2020


After some reflection on the comments, suggestions, and other advice offered
the Hex format API has undergone a significant rewrite.

The improvements include:

  - Merged format and parse classes into a single class HexFormat that 
holds parameters and has methods for all conversions
  - Simplified static factories and added builder methods to create 
HexFormat copies with modified parameters.
  - Consistent naming of methods for conversion of byte arrays to 
formatted strings and back: formatHex and parseHex
  - Consistent naming of methods for conversion of primitive types: 
toHexDigits... and fromHexDigits...
  - Prefix and suffixes now apply to each formatted value, not the 
string as a whole
  - Using java.util.Appendable as a target for buffered conversions so 
output to Writers and PrintStreams
    like System.out are supported in addition to StringBuilder. 
(IOExceptions are converted to unchecked exceptions)

The HexFormat javadoc is at:
http://cr.openjdk.java.net/~rriggs/8251989-hex-formatter/java.base/java/util/HexFormat.html

Thanks to all that commented and made suggestions on core-libs-dev and 
privately.

Please review and comment.  When the API has settled, I'll turn it into 
a PR and CSR.

Thanks, Roger







More information about the core-libs-dev mailing list