-
arrays or tokenizer ?
Hi i am only learning java could any one point me in right direction to my problem. as i have not found any examples to work from.
i need to display a tex box for a user to enter a message
but !!!!
then i have to display this message as sms back to the user
i.e
user message: john see you later before eight
i would need to display : john c u l8 b4 8
please could some one tell me how to go about this, even any examples they might know. as i have read for over a week and can't find any thing that comes near this
thanks
andrew
:mad:
-
Err, so your problem is you cannot display a textbox or you cannot convert see into c?
I'll take it as the latter seeing as your topic starts with StringTokenizer.
Ok, I would use a stringtokenizer as it is very simple to use.
So import java.util.StringTokenizer.
then
StringTokenizer tokenizer = new StringTokenizer(input.getText());
now that you have the tokenizer
String total = "";
while (tokenizer.hasMoreTokens())
{
String temp = tokenizer.nextToken();
if (temp.equals("see")) total += "c ";
else if (temp.equals("you")) total += "u ";
else total += temp + " ";
}
etc
Haven't tested that and I'm not sure if the method names given are correct. I took that off the top of my head so shoot me if it doesn't work. But, I'm sure if something goes wrong you should be able to work it out. Its not too difficult.
Cheers
Marnitz