How to convert a byte array to a hex string in Java?

后端 未结 27 3488
花落未央
花落未央 2020-11-21 04:19

I have a byte array filled with hex numbers and printing it the easy way is pretty pointless because there are many unprintable elements. What I need is the exact hexcode in

27条回答
  •  甜味超标
    2020-11-21 04:54

    Ok so there are a bunch of ways to do this, but if you decide to use a library I would suggest poking about in your project to see if something has been implemented in a library that is already part of your project before adding a new library just to do this. For example if you don't already have

    org.apache.commons.codec.binary.Hex

    maybe you do have...

    org.apache.xerces.impl.dv.util.HexBin

提交回复
热议问题