Java Scanner(Readable source) Constructor
Syntax
Scanner(Readable source) constructor from Scanner has the following syntax.
public Scanner(Readable source)
Example
In the following code shows how to use Scanner.Scanner(Readable source) constructor.
import java.io.StringReader;
import java.util.Scanner;
//from w w w.j av a 2s. c o m
public class Main {
public static void main(String[] args) {
String s = "java2s.com 1 + 1 = 2.0 true ";
Scanner scanner = new Scanner(new StringReader(s));
System.out.println(scanner.nextLine());
// change the radix of the scanner
scanner.useRadix(32);
// display the new radix
System.out.println(scanner.radix());
scanner.close();
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »