-
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
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks