StreamTokenizer is used primarily for reading input files, and has an extensive list of features for tokenizing character streams. StringTokenizer, on the other hand, is extremely simple, used only for tokenizing small strings that might contain keywords and punctuation symbols.
For example, StreamTokenizer know how to take care of Java-style comments. It also knows about quoted strings, words, numbers, etc. The StringTokenizer, on the other hand, does not do any of these things. All it can do is break up a string according to the whitespace and delimiters that are in it.
For more details, see the documentation from the API link in External Links. StreamTokenizer is in java.io, and StringTokenizer is in java.util. |