• 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

Difference and usage of StringTokenizer and String.split()

 
Ranch Hand
Posts: 68
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are the difference between StringTokenizer and String.split()? Which is more faster? which is suitable to operate with large files?
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you could just read the API for StringTokenizer.

"
StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code.
"

 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As DT says, tokenizer has not had a usage for fifteen years. You should not worry about which is faster at this stage. Neither is suitable for use with a file because a file is not in the form of a String. Only when you read a file do you get Strings and the file reading classes all produce multiple Strings representing lines. Some means of reading from text files (e.g. Scanner can translate the text directly into other datatypes (e.g. ints), which would make splitting the String unnecessary.
 
reply
    Bookmark Topic Watch Topic
  • New Topic