Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

How String tokeinzer is advantegous then Strings utility method

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a file ,which contains the lines of records wiht comma seprated.
I want to tokeniz the lines read from the file ,
I am in dillema which one should use

Either I should go for either "String.split()" ro StringTokenizer;

Could any one please explain me the advantage to use any of these and which should be prefferable and will take less amount of time.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps this discussion should answer your question...

http://forum.java.sun.com/thread.jspa?threadID=772447&messageID=4400545
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For most string splitting tasks, the String.split() method is much easier and more natural to use than the StringTokenizer class.

However, StringTokenizer is still useful for some tasks. For example, an overloaded StringTokenizer constructor allows you to specify that the tokens to be returned include the delimiter characters themselves.

Hope this helps.

-Sharada
 
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have never used either, you should do it both ways.
Just to learn how to do it.

Normally you should judge this task on time it takes to implement it and time it may take to maintain the code you've created.

Only in rare cases will the execution time (or execution size) of the code you create actually become an issue (for example: if it's part of a compiler that gets used constantly). Only then should it be used as a data point in your decision of what to do.

And of course, most people just do it the way they know how. =)
 
Do not set lab on fire. Or this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic