This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

StringTokenizer  RSS feed

 
aliya sharma
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm writing this simple program where StringTokenizer takes the string and gives me the result with seperator(which is , in my case). Heres the code:

but when i run my code, Im getting ballot04,expo as my output. I want to get ballot04
expo
I thought StringTokenizer removes/ignores the seperator and gives the result??. Is there something im doing wrong???. THanks for your help

Aliya
 
Scott Dunbar
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to construct your StringTokenizer with the delimeter as it defaults to the space character. Something like:

 
aliya sharma
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Scott, it works fine now.

ALiya
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!