Java Scanner delimiter() method example

HQ ┬╗ Java Tutorial ┬╗ java.util ┬╗ Scanner ┬╗ delimiter() method example
Java Scanner delimiter() method example 2018-02-20T12:06:40+00:00

java.util.Scanner delimiter()

Description :

This java tutorial shows how to use the delimiter() method of Scanner class of java.util package. This method returns a Pattern which the Scanner class is using as a delimiter. This method is simply just to get the delimiter being used by the Scanner class.

Method Syntax :

public Pattern delimiter()

Parameter Input :

DataType Parameter Description

Method Returns :

This method simply returns the Pattern which the Scanner class is using.

Compatibility Version :

Requires Java 1.5 and up

Exception :


Discussion :

The Scanner delimiter() method is helpful to determine what has been used as delimiter in evaluating the string which has been read as declared on the class constructor.

This method is very helpful in error tracing especially on cases that the Scanner object failed to tokenize.

Java Code Example :

This java example source code demonstrates the use of delimiter() method of Scanner class. Basically it prints the delimiter that is being used by the Scanner object scan which is the default pattern since we didn’t specify delimiter to be used. The code then tokenize the String declared on the constructor of the Scanner object.

Sample Output :

Running the delimiter() method example source code of Scanner class will give you the following output

java scanner delimiter() method example

java scanner delimiter() method example

Exception Scenario :


Similar Method :

  • N/A

Suggested Reading List :

References :


Contact Info


Our Goal

JavaTutorialHQ aims to to be The Ultimate Guide on Java with hundreds of examples from basic to advance Topics.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.