GeeCON Prague 2014*
The moose likes Java in General and the fly likes Ascii to hex converter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Ascii to hex converter" Watch "Ascii to hex converter" New topic
Author

Ascii to hex converter

Ghaith Shamayleh
Greenhorn

Joined: Apr 13, 2011
Posts: 14
I would like if there is a function in java that can be used to covert a string of ascii to a string of hex, or should i write a method to write this, can anyway help
Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
This one does it one character at a time; I'm actually cramming unicode into byte, but if you have ASCII (in 7 or 8 bits), it will cast to byte as well.

Look up details for formatting string output under java.util.Formatter

rc>
Ghaith Shamayleh
Greenhorn

Joined: Apr 13, 2011
Posts: 14
this will take a string of hex and convert it or a string of ascii and covert it
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39053
    
  23
What is a String of hex? Do you mean a String which only contains the characters 0-9 a-f and A-F? Your last comment appears to want the opposite of what the thread title says you want.
Ghaith Shamayleh
Greenhorn

Joined: Apr 13, 2011
Posts: 14
i got it cheers everyone
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39053
    
  23
Well done
 
GeeCON Prague 2014
 
subject: Ascii to hex converter