Tokenize

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Feb 2007
Posts: 46
Reputation: torbecire is an unknown quantity at this point 
Solved Threads: 0
torbecire torbecire is offline Offline
Light Poster

Tokenize

 
0
  #1
Apr 17th, 2008
I am having a problem with tokenizing "wddw". I can tokenize if they is a sign like (,). How can I tokenize this without getting an error. I have tried charAt(0), but it only gives me the first character.

I want each character to be stored separately. I know about split, but I need to use tokenizer

    public static void main(String [] args)
    {
        String temp = "wddw";
StringTokenizer st = new StringTokenizer(temp);
while (st.hasMoreTokens())
{
    char del;
    String com = st.nextToken();
    int x = com.lastIndexOf(com);
    del = com.charAt(0);
    System.out.println(del);   
}
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 22
Reputation: Samudricka is an unknown quantity at this point 
Solved Threads: 1
Samudricka's Avatar
Samudricka Samudricka is offline Offline
Newbie Poster

Re: Tokenize

 
0
  #2
Apr 17th, 2008
i think it is better to use character array to store each character and get it....sample syntax is like this.....
  1. char[] i=new char[10]; String u = (String) stoke.nextToken(); i= u.toCharArray();
So that you can get as each character.......
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 791 | Replies: 1
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC