• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Regarding String Tokenizer

 
Ranch Hand
Posts: 203
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks ,

I was going through the example of string tokenizer .. as StringTokennizer to split a string by “space” and “comma” delimiter, and iterate the StringTokenizer elements and print it out one by one.




and the expected out put was....



My query was do any other alternative do we have to achieve the same thing...as regex , pattern matcher do we have...if yes please show a demo just like that to achieve the same thing..!!
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Saral Saxena wrote:
My query was do any other alternative do we have to achieve the same thing...as regex , pattern matcher do we have...if yes please show a demo just like that to achieve the same thing..!!


Haeyou tried String#split(regex). I suspect it internally it uses regex, (pattern and matcher), but please look at String class code to get confirms.
 
Saral Saxena
Ranch Hand
Posts: 203
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

My query was do any other alternative do we have to achieve the same thing...as regex , pattern matcher do we have...if yes please show a demo just like that to achieve the same thing..!!

Sagar Rohankar wrote:
Haeyou tried String#split(regex). I suspect it internally it uses regex, (pattern and matcher), but please look at String class code to get confirms.



Thanks a lot..could you please show a small example on that..!!
 
Bartender
Posts: 10777
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Saral Saxena wrote:My query was do any other alternative do we have to achieve the same thing...as regex , pattern matcher do we have...if yes please show a demo just like that to achieve the same thing..!!


If you look at the API docs for StringTokenizer, you'll see that it's a "legacy class" and that its use is discouraged. At the same place, it also tells you what you can use instead.

Thanks a lot..could you please show a small example on that..!!


I suggest you look at a good tutorial. A quick Google produced me many hits, most of which have examples.

Winston
    Bookmark Topic Watch Topic
  • New Topic