StringTokenizer


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: StringTokenizer

Hybrid View

  1. #1
    archie Guest

    StringTokenizer


    i has been try to use stringTokenizer class for parsing a file and identifying
    certain details
    eg String s= " please i want help"
    if to use StringTokenizer on this string by default it is supposed to break
    the string usin whites spaces that is to
    please
    i
    want
    help
    i am getting this expected output but if i want to check if something is
    in the token stream eg
    if(s.nextToken()=="please")
    {
    // do something
    }
    i get unexpected result ,ie on no occassion is this condition satisfied
    and executed but i know please should be in the token stream i am even printing
    the token stream and seeing it

    please help what could be the problem

  2. #2
    Paul Clapham Guest

    Re: StringTokenizer

    Your problem is nothing to do with StringTokenizer.

    Don't use "==" to compare the contents of two Strings. That doesn't work.
    Use the equals() method instead:

    if (s.nextToken().equals("please"));

    PC2

    "archie " <archieforlife@yahoo.com> wrote in message
    news:3adac298$1@news.devx.com...
    >
    > i has been try to use stringTokenizer class for parsing a file and

    identifying
    > certain details
    > eg String s= " please i want help"
    > if to use StringTokenizer on this string by default it is supposed to

    break
    > the string usin whites spaces that is to
    > please
    > i
    > want
    > help
    > i am getting this expected output but if i want to check if something is
    > in the token stream eg
    > if(s.nextToken()=="please")
    > {
    > // do something
    > }
    > i get unexpected result ,ie on no occassion is this condition satisfied
    > and executed but i know please should be in the token stream i am even

    printing
    > the token stream and seeing it
    >
    > please help what could be the problem




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center