If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

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

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