StrikTokenizer is still faster. If it can do the job, use it. For more complex splitting, use the regex engine as you found out.
# posted by Anonymous : 7/14/2004 05:51:51 AM
You are right.
There is a huge performance difference.
# posted by Lokesh : 7/14/2004 07:00:18 AM
I’ve not benchmarked this, but if performance becomes an issue, then precompiling the regex should improve things:
private static final Pattern splitPattern = Pattern.compile(“:”);
# posted by Anonymous : 7/14/2004 11:55:20 AM
Precompiling certainly improves performance, but for simple splits, StringTokenizer performs much better.
# posted by Lokesh : 7/14/2004 05:23:32 PM