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