Results 1 to 2 of 2

Thread: type casting tokenizer

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    5

    type casting tokenizer

    Me again!

    I've got an input from a single string that is separated by "&" so I'm using a tokenizer to split it up. The problem is that two of the inputs in the string don't want to be strings, one must be double and the other int.

    I've currently got:

    Code:
            ...
            private int quantity;
    
            StringTokenizer st = new StringTokenizer(order, "&");
            while (st.hasMoreTokens())
            {
                dateRaised = (st.nextToken());
                ...
                ...
                quantity = Integer.parseInt(st.nextToken());
            }

    but the output for the int is 0. Where am I going wrong?

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

    Re: type casting tokenizer

    nextToken might not be an integer, that's your mistake
    "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