Article View: borland.public.jbuilder.java.language
Article #17030Re: Converting from ASCII
From: Ken Fishkin
Date: Tue, 29 Dec 1998 00:00
Date: Tue, 29 Dec 1998 00:00
19 lines
1247 bytes
1247 bytes
matt lopresti wrote: > i am writing a program that takes in a phone number, and converts it to > letters, as to make the phone number easier to remember. I have taken > the phone number and converted to getBytes, this assigns the ASCII value > to the numbers, the Question is: how then do I convert it back? Here is > the code snippet: > > String phoneNumber ="6479037"; > byte[] numAsArray = phoneNumber.getBytes(); > several possibilities: 1) use Character.digit() on each digit in (numAsArray), Characters can easily be turned into Strings. 2) use Byte.toString() on each digit, append Strings to Strings 3) as of JDK 1.1, there are String constructors that take arrays of bytes.
Technical Details
Message-ID:
<368930B8.3F222700@parc.xerox.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<36880E9A.7A2C8F8@toad.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,b7f932c95abe3579 X-Google-Attributes: gidf74b3,public From: Ken Fishkin <fishkin@parc.xerox.com> Subject: Re: Converting from ASCII Date: 1998/12/29 Message-ID: <368930B8.3F222700@parc.xerox.com> X-Deja-AN: 426858500 Content-Transfer-Encoding: 7bit References: <36880E9A.7A2C8F8@toad.net> Content-Type: text/plain; charset=us-ascii Organization: Xerox PARC Mime-Version: 1.0 Reply-To: fishkin@parc.xerox.com Newsgroups: borland.public.jbuilder.java.language