[11] RFR: 8170769 Provide a simple hexdump facility for binary data

Vincent Ryan vincent.x.ryan at oracle.com
Wed May 9 22:49:20 UTC 2018


Thanks for your comments Max.

> On 9 May 2018, at 03:34, Weijun Wang <weijun.wang at oracle.com> wrote:
> 
> Nice tool.
> 
> However, I am not sure how toFormattedHexString() and toPrintableString() are useful, seems only for providing a customizable dump format which is, actually, not very customizable.

These provide implementations only to generate the human-readable hexdump format. 
They are not designed to be customizable. Custom formats should be supplied via Hex.Formatter.


> 
> For me, toHexString and fromHexString are of course the most useful methods. As for dump, I can only think of
> 
> 1. The existing sun.security.HexDumpEncoder format, when I want to dump a lot of bytes as a block
> 2. "00:11:22:33:AA:BB:CC" which fits in one line and also easy to read, when I want inline debugging output
> 
> If the customizable dump method is both powerful and simple enough to create 2) above, I'll be happy. Otherwise, I can live with toHexString().replaceAll("(..)(?=.)", "$1:”).

How about adding another toHexString method that takes a delimiter character?

> 
> Thanks
> Max
> 
>> On May 4, 2018, at 4:22 AM, Vincent Ryan <Vincent.X.Ryan at oracle.com> wrote:
>> 
>> Hello,
>> 
>> Please review this proposal for a new API to conveniently generate and display binary data using hex string representation.
>> It supports both bulk and stream operations and it can also generate the well-known hexdump format [1].
>> 
>> Thanks
>> 
>> 
>> Bug: https://bugs.openjdk.java.net/browse/JDK-8170769
>> API: http://cr.openjdk.java.net/~vinnie/8170769/javadoc.05/api/java.base/java/util/Hex.html
>> Webrev: http://cr.openjdk.java.net/~vinnie/8170769/webrev.05/
>> 
>> ____
>> [1] https://docs.oracle.com/cd/E86824_01/html/E54763/hexdump-1.html
> 



More information about the core-libs-dev mailing list