• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

StringTokenizer

 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anyone know why StringTokenizer is no longer "preferred"? I have looked at the Split method, but can see no way to retrieve which one of a list of possible separators was used. StringTokenizer lets me retrieve the separators as tokens. I hope that StringTokenizer isn't going to be deprecated ...

Thanks!
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
split() takes a regular expression. If you don't want to loose any tokens when you split() then use a zero-width assertion, or a series of them.

Split at all word boundaries...


There are loads of ways to tokenize the strng in a lossless fashion

If you're trying to do anything more than a basic split however then there's a pretty good chance you really do have to tokenize the string manually.
 
reply
    Bookmark Topic Watch Topic
  • New Topic