Java Scanner reset() Method
Example
Reset changes made to the scanner's configuration:
// Create a scanner object
Scanner myObj = new Scanner("A string to scan");
// Change configuration
myObj.useDelimiter(",");
myObj.useLocale(new Locale("es"));
myObj.useRadix(16);
// Reset the configuration
myObj.reset();
// Read configuration values
System.out.println(myObj.delimiter());
System.out.println(myObj.locale());
System.out.println(myObj.radix());
Definition and Usage
The reset() method resets all changes to the scanner's configuration. Configuration of the scanner can be changed by the useDelimiter(), useLocale() and useRadix() methods.
Syntax
public Scanner reset()
Technical Details
| Returns: | A reference to the Scanner object that this method belongs to, which allows for chaining configuration methods. An example of chaining is myObj.reset().useDelimiter(",");. |
|---|---|
| Java version: | 1.6+ |