Delphi Clinic | C++Builder Gate | Training & Consultancy | Delphi Notes Weblog | Dr.Bob's Webshop |
|
Reset the StreamTokenizer
In the java.io package we can find a nice little class called the StreamTokenizer.
This class takes a input stream or reader class and parses the input stream or reader class.
We customize the behaviour of this class by invoking different methods.
For example we can tell the StreamTokenizer to treat all text following a special character as comment by invoking the commentChar(int ch) method.
But it is very important to invoke the resetSyntax() method first on a newly created instance of a StreamTokenizer class. Because if we don't do this the StreamTokenizer object will use the settings from the private constructor of the StreamTokenizer class. And the settings set by the constructor aren't necessarly the ones we want to use. For example in the private constructor the parseNumbers() method is invoked, telling the object to treat number as special tokens, but maybe we don't want this for our instance.
So if we are using this class and we don't get the exact behaviour we would expect it is good to check if we have invoke the resetSyntax() method.