aspose file tools
The moose likes Java in General and the fly likes Binary String to Hexadecimal value problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Binary String to Hexadecimal value problem" Watch "Binary String to Hexadecimal value problem" New topic
Author

Binary String to Hexadecimal value problem

J amodi
Greenhorn

Joined: Nov 09, 2011
Posts: 14
Hi,

I need to convert binary string (e.g 01110111) to hexadecimal value.

If I am using this code


then it is getting rid of initial 0s After converting in integer. above code will output me only "f" instead of "0f". Could anyone help me to resolve this issue ?

Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 3133
You already have one thread that seems to be the same as this one. Please UseOneThreadPerQuestion.(⇐click)
Martin Vajsar
Bartender

Joined: Aug 22, 2010
Posts: 1219

There is a String.format() function, which takes a format string and a parameter (or parameters) and can be used to output formatted strings. The format string allows you to specify flags to modify the output of the method. I suppose you could put this method to good use, just look it up in the documentation.
Mohamed Sanaulla
Bartender

Joined: Sep 08, 2007
Posts: 2694

Jeff Verdegan wrote:You already have one thread that seems to be the same as this one. Please UseOneThreadPerQuestion.(⇐click)

Is this the thread you were referring to? I am not sure if they are similar, as the other thread was converting Binary value to ASCII.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 3133
Mohamed Sanaulla wrote:
Jeff Verdegan wrote:You already have one thread that seems to be the same as this one. Please UseOneThreadPerQuestion.(⇐click)

Is this the thread you were referring to? I am not sure if they are similar, as the other thread was converting Binary value to ASCII.


Yeah, that's the one. I guess I was confused.
 
 
subject: Binary String to Hexadecimal value problem
 
Threads others viewed
Octal number conversion
how to convert hexadecimal value in int value
Hexadecimal Numbers
Hexadecimal and decimal convert code
How can i give binary value to int?
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture