Example usage for java.util Scanner locale

List of usage examples for java.util Scanner locale

Introduction

In this page you can find the example usage for java.util Scanner locale.

Prototype

Locale locale

To view the source code for java.util Scanner locale.

Click Source Link

Usage

From source file:Main.java

public static void main(String[] args) {

    String s = "java2s.com 1 + 1 = 2.0 ";

    Scanner scanner = new Scanner(s);

    // print the line
    System.out.println(scanner.nextLine());

    // print the current locale
    System.out.println(scanner.locale());

    scanner.close();// ww w.jav  a  2  s .  c  om
}

From source file:Main.java

public static void main(String[] args) {

    String s = "java2s.com 1 + 1 = 2.0 true ";

    Scanner scanner = new Scanner(s);

    System.out.println(scanner.nextLine());

    // change the locale of the scanner
    scanner.useLocale(Locale.ENGLISH);

    // display the new locale
    System.out.println(scanner.locale());

    scanner.close();/*from  w  w  w. ja  va 2 s  . com*/
}

From source file:Main.java

public static void main(String[] args) {

    String s = "java2s.com 1 + 1 = 2.0 true ";

    Scanner scanner = new Scanner(s);

    System.out.println(scanner.nextLine());

    // change the locale of this scanner
    scanner.useLocale(Locale.US);

    // change the radix of this scanner
    scanner.useRadix(30);//from   w w w  .j  a v  a  2  s .  c o m

    // reset and check the values for radix and locale, which are the default
    scanner.reset();
    System.out.println(scanner.radix());
    System.out.println(scanner.locale());

    scanner.close();
}