I don't have the time to make a login and reply right now, however...
The String.indexOf is probably the best thing suggested on the board.
A better answer would probably be to read the whole file into memory, then search it via a Boyer Moore Horspool algorythm. Package pat uses this if the pattern is a string literal. To avoid some of the overhead of regex's you can use the SkipBMH class contained within it. The BMH algorythem can find things faster than indexOf().
One key to speed is making fewer Strings. That is why I recommend reading
the whole file into memory (if possible).
Once you've found the item you're looking for, you can backtrack to find the beginning and end of the line -- then maybe you can use things like
substring or StringTokenizer.
Of course, this assumes you have a fairly normal CSV file. In principle, CVS allows you to put newlines in quotes, making them part of a field,
and so on. This kind of processing can get quite complex.
Originally posted by Greg Kearn:
To speed the search the data is pre-sorted into 3 files, citydata, areadata and zipdata. The key field is the first field in the row. Ex citidata: Miami, 305, 33341, E. zipdata: 33341, Miami, 305, E. areadata: 305, Miami, 33341, E.
Is it possible to index this file?
It wasn't my idea to go to some crazy nightclub in the middle of nowhere. I just wanted to stay home and cuddle with this tiny ad:
Thread Boost featurehttps://coderanch.com/t/674455/Thread-Boost-feature