Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SwingTokenizer

 
Chandra Moulee
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the StringTokenizer class.I create an StringTokenizer object.This is what i do.
String s="a,,,b";
StringTokenizer s1=new StringTokenizer(s,",");
It should give me 5tokens.But it is giving me only 1.
,,, should be treated as null rite.

Thanks
Mouli
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, that will give you two tokens ("a" and "b").
 
Seb Mathe
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're JDK version is >1.4 it's better to use String's split method :
"a,,,,b".split(",") will return an array of 5 String objs.
[ September 29, 2005: Message edited by: Seb Mathe ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic