Results 1 to 2 of 2

Thread: arrays or tokenizer ?

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2002
    Location
    liverpool
    Posts
    9

    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

  2. #2
    Hyperactive Member marnitzg's Avatar
    Join Date
    Oct 2000
    Location
    South Africa
    Posts
    372
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width