The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
April 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

cast to char

Posted by Siddhant Kumar on May 22, 2001 at 3:33 AM

type cast it to char


> Ok Im using the stringBuffer for the first time in a client server program im trying to use the stringBuffer to store the sent characters from the server and to then display the results on screen. The problem is that when it displays the result on screen it comes up as a string of numbers rather than the string or character that was sent from the server.

> Below is the code im using:

> else { // this is the client which receives characters
> StringBuffer receiveString = new StringBuffer();
> int receiveChar;

> System.out.print ("Characters received:");

> do {
> receiveChar = comms.read ();
> receiveString.append(receiveChar);
> System.out.print (receiveString.toString());
> } while (receiveChar != 'q');

> }

> Any help assistance, telling me everything I have written is fine but any help that can be supplied is going to be helpful



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us