❮ Scanner Methods
Example
Show the delimiter that is currently being used by the scanner:
// Create a scanner object Scanner myObj = new Scanner("A string to scan");
// Find the delimiter System.out.println(myObj.delimiter());
// Close the scanner myObj.close();Definition and Usage
The delimiter() method returns a Pattern object describing the sequence of characters which separates tokens in the data being scanned. The default delimiter is a sequence of whitespace characters, but it can be changed with the useDelimiter() method.
Learn more about the Pattern object in our Java RegEx tutorial .
What is a token?
A token is a sequence of characters separated from other tokens by delimiters.
Syntax
public Pattern delimiter()Technical Details
| Returns: | A Pattern object describing the sequence of characters that the scanner uses as a delimiter. |
|---|
❮ Scanner Methods