String and StringTokenizer
What is difference between String and StringTokenizer?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Lakshmanan Sethu SankaranarayanPosted Apr 17, 2014, 9:21 AM
Munesh SharmaPosted Apr 17, 2014, 7:48 AM
You can think of the StringTokenizer as a specialized form of StreamTokenizer, where each token that is returned is a String. Depending upon what you want to do with the resultant tokens and/or how complex of a parse job you want to deal with lets you decide which to use.
The StringTokenizer parses a string into a series of tokens. It is then your responsibility to figure out what each token returned is, beyond the definition of a token separated by delimiters. Usually, you just treat things as words when using StringTokenizer.
On the other hand, a StreamTokenizer allows you to ask is the next token a number, word, quoted string, end-of-file, end-of-line, comment, or whitespace. In this case, the StreamTokenizer is smarter, though can be considerably harder to use.
VulpesPosted Apr 17, 2014, 5:21 AM
Note that this question relates to Java, not C# (and Lakshmanan has answered accordingly) because .NET doesn't have a StringTokenizer class.
Lakshmanan Sethu SankaranarayanPosted Apr 17, 2014, 1:11 AM