Results 1 to 3 of 3

Thread: StringTokenizer Issue

  1. #1

    Thread Starter
    Hyperactive Member xxarmoxx's Avatar
    Join Date
    Mar 2007
    Posts
    378

    StringTokenizer Issue

    Here is the code im working with:

    Code:
          
    
    int i=0;
    
     String iLine = in.readLine();
            
            // Tokenize
            st = new StringTokenizer(iLine,",");
    
        while (st.hasMoreTokens()) { 
                    
                         r[i] = st.nextToken();
    
                         
                         i++;
              
                    }

    Here is the Data Im working with:

    Hilton,15,,2,,



    The tokens Im getting are as follows:

    Hilton
    15
    2


    But what I need is

    Hilton
    15

    2



    I need to get that blank token, how can I get it?

    Thanks!

  2. #2

    Thread Starter
    Hyperactive Member xxarmoxx's Avatar
    Join Date
    Mar 2007
    Posts
    378

    Re: StringTokenizer Issue

    I'll answer my own question. Just use this class http://geosoft.no/software/tokenizer...izer.java.html

  3. #3
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: StringTokenizer Issue

    or you can use the String.split method instead
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

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