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?
Java

Avatar of undefined
Last Comment
plusone3055

8/22/2022 - Mon
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
plusone3055

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23