[2424] in java-interest

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

Converting an int to a char?

daemon@ATHENA.MIT.EDU (John M Begenisich)
Sun Oct 1 18:50:32 1995

Date: Sun, 1 Oct 1995 16:32:34 -0400 (EDT)
From: John M Begenisich  <begenisi@oswego.Oswego.EDU>
To: java-interest@java.sun.com
In-Reply-To: <199509291400.HAA18403@java.sun.com>


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