[2448] in java-interest

home help back first fref pref prev next nref lref last post

Re: Converting an int to a char?

daemon@ATHENA.MIT.EDU (Arthur van Hoff)
Mon Oct 2 22:07:50 1995

Date: Mon, 2 Oct 1995 10:15:01 -0700
From: Arthur.Vanhoff@Eng.Sun.COM (Arthur van Hoff)
To: begenisi@oswego.Oswego.EDU
Cc: java-interest@java.Eng.Sun.COM


Hi John,

This has been fixed in the beta APIs. Yo make this work in alpha3 as
follows:

	char data[] = {(char)b};
	line += new String(data);
	
Have fun,

	Arthur van Hoff
	

> I'm trying to convert an int to a character.  This is what I basically 
> have:
> 
>   String line = new String();
>   int dum=0;
>   while ((dum=(int)data.read())!=-1) {
>     b=(char)dum;
>     line+=(char)b;
>     ...blah blah blah...
>   }
>   System.out.print(line);
> 
> And, after a text file was read, I get a stream of numbers:
> 
>   46445745725145238945423451242140246024576
> 
> which corresponds to the ascii values of the characters I input.
> 
> In Pascal, I would write:
> 
>   c : char;
>   b : byte;
>   s : string;
> 
>   b := 53;
>   c := chr(b);
>   s := s + c;
> 
>   Write(c);
> 
> ... and it would work.
> 
> How do I convert an int to a char?
> 
> Thanks,
> John
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post