Example usage for java.util Scanner close

List of usage examples for java.util Scanner close

Introduction

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

Prototype

public void close() 

Source Link

Document

Closes this scanner.

Usage

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.next("."));

    scanner.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Scanner scanner = new Scanner(new File("c:/text.txt"));
    System.out.println(scanner.nextLine());

    scanner.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Scanner scanner = new Scanner(new FileInputStream("c:/text.txt"));
    System.out.println(scanner.nextLine());

    scanner.close();
}

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);

    scanner.skip("java2s");

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

    scanner.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Scanner scanner = new Scanner(new File("c:/text.txt"), StandardCharsets.UTF_8.name());
    System.out.println(scanner.nextLine());

    scanner.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Scanner scanner = new Scanner(FileSystems.getDefault().getPath("logs", "access.log"));
    System.out.println(scanner.nextLine());

    scanner.close();
}

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 next line of the string
    System.out.println(scanner.nextLine());

    scanner.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Scanner scanner = new Scanner(new FileInputStream("c:/text.txt"), StandardCharsets.UTF_8.name());
    System.out.println(scanner.nextLine());

    scanner.close();
}

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());

    System.out.println("" + scanner.toString());

    scanner.close();
}

From source file:Main.java

public static void main(String[] args) {

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

    Scanner scanner = new Scanner(s);

    // scan next token as a Big Integer with radix 4
    System.out.println(scanner.nextBigInteger(4));

    scanner.close();
}