Hi, I don't know if performance is an issue. But if it is, I think it world make sense to use a precompute array. And replace
private static int hexToBinary(char ch) { if ('0' <= ch && ch <= '9') { return ch - '0'; } if ('A' <= ch && ch <= 'F') { return ch - 'A' + 10; } if ('a' <= ch && ch <= 'f') { return ch - 'a' + 10; } return -1; } with private static int hexToBinary(char ch) { return ch <= 'f' ? staticPrecomputedArray[ch] : -1; } where int[] staticPrecomputedArray is computed in a static initializer block. /Kasper On Fri, 23 Nov 2018 at 14:51, Vincent Ryan <vincent.x.r...@oracle.com> wrote: > Hello, > > Please review this proposal for a new API to conveniently generate and > display binary data using hexadecimal string representation. > It supports both bulk and stream operations and it can also generate the > well-known hexdump format [1]. > > This latest revision addresses review comments provided earlier. > These include adding methods to support for data supplied in a > ByteBuffer, exposing the default formatter implementation as a public > static and dropping the superfluous 'Hex' term from several method names. > > Thanks > > > Bug: https://bugs.openjdk.java.net/browse/JDK-8170769 > API: > > http://cr.openjdk.java.net/~vinnie/8170769/javadoc.06/api/java.base/java/util/Hex.html > Webrev: http://cr.openjdk.java.net/~vinnie/8170769/webrev.06/ > > > ____ > [1] https://docs.oracle.com/cd/E88353_01/html/E37839/hexdump-1.html >