Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Is there any method in Java that will convert hexadecimal characters to binary characters?

0
Posted

Is there any method in Java that will convert hexadecimal characters to binary characters?

0

Location: http://www.jguru.com/faq/view.jsp?EID=451751 Created: Jul 8, 2001 Modified: 2001-08-18 19:07:01.613 Author: Tim Rohaly (http://www.jguru.com/guru/viewbio.jsp?EID=10) Question originally posed by Sunil R (http://www.jguru.com/guru/viewbio.jsp?EID=446378 You can use Integer.parseInt() or Long.parseLong() to convert a hexadecimal representation to a 4-byte int or an 8-byte long, respectively. For example, the Java class file magic number 0xCAFEBABE can be converted to the long value 3405691582 using long magic = Long.parseLong(“CAFEBABE”, 16); where the second argument to the method represents the radix used to encode the first parameter (in this case, base 16, or hexadecimal). You can also convert hexadecimal number directly into Integer or Long objects using the methods Integer.decode() or Long.decode(), respectively. If you wish to subsequently print out these values as a String in base 2 (binary), you can use either Integer.toBinaryString() or Long.toBinaryString(). See the

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.