Link to home
Start Free TrialLog in
Avatar of cgray1223
cgray1223

asked on

Using Java how do I convert hex to bytes to bits

Hello,

I have a hex String of 01234 how do I convert that to bytes and then to bits?  An example of a requirement that I have is to inspect bit 2 of byte 1 and based on its value (1 or 0) do some logic.  What is the most efficient way to accomplish this conversion?
Avatar of centic
centic

I would probably take a look at http://commons.apache.org/codec/, this small library contains codecs for all these things, like Hex and Binary. Look at http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/Hex.html and http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/BinaryCodec.html

Dominik.
ASKER CERTIFIED SOLUTION
Avatar of plusone3055
plusone3055
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial