Java Language Tutorial:

Java Language Scanner

Syntax

  • Scanner scanner = new Scanner(Source source);
  • Scanner scanner = new Scanner(System.in);

Parameters

ParameterDetails
SourceSource could be either one of String, File or any kind of InputStream

Remarks

The Scanner class was introduced in Java 5. The reset() method was added in Java 6, and a couple of new constructors were added in Java 7 for interoperability with the (then) new Path interface.

Java Language Scanner Examples:

Related Java Language Tutorial Topics:

Other Tutorial Topics:

This modified content is an extract of the original Stack Overflow Documentation released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow. This topic was created and modified by the Stack Ovedrflow Contributor.