Article View: borland.public.jbuilder.java.language
Article #8495Re: Converting Ordinary String to Hex Representation
From: andu123
Date: Thu, 15 Mar 2001 09:22
Date: Thu, 15 Mar 2001 09:22
34 lines
1579 bytes
1579 bytes
Hi,
sample code:
String s = "k";
char c = s.charAt(0) ;
byte b = (byte) c;
System.out.println("byte:" + b);
System.out.println("hex:" + Integer.toHexString(b));
Watch out: method Integer.toHexString trims the leading "0"!!!
Read api doc for more info.
andru123
On Wed, 14 Mar 2001 22:48:59 -0800, "Harry Whitehouse"
<harry@envmgr.com> wrote:
>I need to convert a simple text string to the hex representation of that
>string. That representation in of itself should be another string. For
>instance in the string was "1 2" (The number 1, a space, and the number 2)
>I would want a HEX presentation of "312032".
>
>I've been through a ton of classes, but I can't seem to find the way to pull
>this off.
>
>Any thoughts?
>
>TIA
>
>Harry
>
>
Technical Details
Message-ID:
<3ab089e6.4428638@news.iae.nl>Path:
arc1-ca.pugleaf.net!pubnews.netcom.net.uk!diablo.netcom.net.uk!netcom.net.uk!dispose.news.demon.net!demon!news.maxwell.syr.edu!newsfeed.novia.net.MISMATCH!novia!calwebnntp!news.IAEhv.nl!not-for-mailReferences:
<3ab065d9$1_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,2d3641429c1fd31 X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-03-17 07:55:10 PST Path: arc1-ca.pugleaf.net!pubnews.netcom.net.uk!diablo.netcom.net.uk!netcom.net.uk!dispose.news.demon.net!demon!news.maxwell.syr.edu!newsfeed.novia.net.MISMATCH!novia!calwebnntp!news.IAEhv.nl!not-for-mail From: andru123@hotmail.com (andu123) Newsgroups: borland.public.jbuilder.java.language Subject: Re: Converting Ordinary String to Hex Representation Date: Thu, 15 Mar 2001 09:22:51 GMT Organization: Internet Access Eindhoven, the Netherlands Lines: 35 Message-ID: <3ab089e6.4428638@news.iae.nl> References: <3ab065d9$1_1@dnews> NNTP-Posting-Host: simac2.iae.nl X-Newsreader: Forte Free Agent 1.21/32.243