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:eu.openanalytics.rsb.SuiteITCase.java

/**
 * To help with any sort of manual testing.
 *///from   w w  w .j  a v a 2 s .  co m
public static void main(final String[] args) throws Exception {
    setupTestSuite();

    System.out.println("Type ENTER to stop testing...");
    final Scanner scanner = new Scanner(System.in);
    scanner.nextLine();
    scanner.close();

    teardownTestSuite();
}

From source file:com.frederikam.fredboat.bootloader.Bootloader.java

public static void main(String[] args) throws IOException, InterruptedException {
    OUTER: while (true) {
        InputStream is = new FileInputStream(new File("./bootloader.json"));
        Scanner scanner = new Scanner(is);
        JSONObject json = new JSONObject(scanner.useDelimiter("\\A").next());
        scanner.close();

        command = json.getJSONArray("command");
        jarName = json.getString("jarName");

        Process process = boot();
        process.waitFor();/*from   www  . j  a  v  a 2 s. c  o m*/
        System.out.println("[BOOTLOADER] Bot exited with code " + process.exitValue());

        switch (process.exitValue()) {
        case ExitCodes.EXIT_CODE_UPDATE:
            System.out.println("[BOOTLOADER] Now updating...");
            update();
            break;
        case 130:
        case ExitCodes.EXIT_CODE_NORMAL:
            System.out.println("[BOOTLOADER] Now shutting down...");
            break OUTER;
        //SIGINT received or clean exit
        default:
            System.out.println("[BOOTLOADER] Now restarting..");
            break;
        }
    }
}

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

    // print the delimiter this scanner is using
    System.out.println(scanner.delimiter());

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

    // change the radix of the scanner
    scanner.useRadix(32);//w w  w .j  a v  a2  s.co m

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

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

    while (scanner.hasNext()) {
        // check if the scanner's next token is an int
        System.out.println(scanner.hasNextInt());

        System.out.println(scanner.next());
    }//from  w w  w. j a  v a 2 s  .  c o  m
    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);

    while (scanner.hasNext()) {
        // check if the scanner's next token is a byte
        System.out.println(scanner.hasNextByte());

        System.out.println(scanner.next());
    }//from w  ww. j  a va 2  s  .c o m
    scanner.close();
}

From source file:Main.java

public static void main(String[] args) {

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

    Scanner scanner = new Scanner(s);

    while (scanner.hasNext()) {
        // check if the scanner's next token is a boolean
        System.out.println(scanner.hasNextBoolean());

        System.out.println(scanner.next());
    }//  www .j  a v a 2 s  .  c  o m
    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);

    while (scanner.hasNext()) {
        // check if the scanner's next token is a BigInteger
        System.out.println(scanner.hasNextBigInteger());
        System.out.println(scanner.next());
    }/*from  w  w w  .j  av  a2 s  .c om*/
    scanner.close();
}

From source file:TextFileTest.java

public static void main(String[] args) {
    Employee[] staff = new Employee[3];

    staff[0] = new Employee("Carl Cracker", 75000, 1987, 12, 15);
    staff[1] = new Employee("Harry Hacker", 50000, 1989, 10, 1);
    staff[2] = new Employee("Tony Tester", 40000, 1990, 3, 15);

    try {/*from   w w w .  jav a2 s  .  c o  m*/
        // save all employee records to the file employee.dat
        PrintWriter out = new PrintWriter("employee.dat");
        writeData(staff, out);
        out.close();

        // retrieve all records into a new array
        Scanner in = new Scanner(new FileReader("employee.dat"));
        Employee[] newStaff = readData(in);
        in.close();

        // print the newly read employee records
        for (Employee e : newStaff)
            System.out.println(e);
    } catch (IOException exception) {
        exception.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {

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

    Scanner scanner = new Scanner(s);

    // find a pattern of any letter plus "com"
    System.out.println(scanner.findInLine(Pattern.compile(".com")));

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

    scanner.close();
}