my dog learned polymorphism*
The moose likes Performance and the fly likes String Tokenizer or Regex Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "String Tokenizer or Regex" Watch "String Tokenizer or Regex" New topic
Author

String Tokenizer or Regex

Ashwath Rangan
Greenhorn

Joined: Jan 30, 2007
Posts: 6
I need to read text from a CSV file where i use "|" as seperators. I am wondering if i should be using String Tokenizer or Regular expressions. Can any body help me in deciding wich is faster.

Thanks in advance
Arulanand Dayalan
Ranch Hand

Joined: Aug 10, 2005
Posts: 124
Regular Expression are faster.

Thanks and Regards,
Arul.
Alan Moore
Ranch Hand

Joined: May 06, 2004
Posts: 262
It doesn't matter whether StringTokenizer or split() is faster; neither one is the right tool for this job. For standard CSV data, I would recommend a dedicated CSV parser/tokenizer, but it sounds like Stephen Ostermiller's StringTokenizer replacement will suit your needs better:

http://ostermiller.org/utils/StringTokenizer.html
Chris Beckey
Ranch Hand

Joined: Jun 09, 2006
Posts: 116

If you are reading from files (as in FileInputStream() or FileReader()) then java.io.StreamTokenizer is another possibility if the parsing is reasonably simple.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String Tokenizer or Regex
 
Similar Threads
How can i check for empty JTextfield and get one line at a time from a JTextArea?
Extract an Email From a String literal
message
JLIST Store and retreive data to Properties
I think I have a memory leak: 33 megs of char arrays.. what to do?