> Is there a way to tokenize StringBuffer, without
> converting it into toString(). I heard that
> StringBuffer's toString() does a lazy copy. So,
> tokenizing will be inefficient when the StringBuffer
> holds huge data, since you have to call its toString
> before tokenizing.
you can use these methods at StringBuffer if you don't use StringTokenizer
1. indexOf - find index for specific delimeter or tokenizer
2. substring - split the result
Instead of StringTokenizer, you can probably use the Pattern and Matcher classes. They'll work with StringBuffer directly, because it implements CharSequence. Avoid the split() methods, and use the group() methods sparingly, and you should be able to keep the number of String objects to a minimum.
http://java.sun.com/docs/books/tutorial/essential/regex/index.html