Java Scanner Usage close()

Here you can find the source of close()

Description

close

License

Open Source License

Declaration

public static void close() 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    private static Map<Long, Scanner> map = new HashMap<>();

    public static void close() {
        Scanner keyboardScanner = getThreadScanner();

        if (keyboardScanner != null) {
            keyboardScanner.close();/*from w w  w .  ja v  a  2  s  .c om*/
            keyboardScanner = null;
        }
    }

    private static Scanner getThreadScanner() {
        long threadId = Thread.currentThread().getId();
        Scanner keyboardScanner = map.get(threadId);
        return keyboardScanner;
    }
}

Related

  1. asList(String source, String separator)
  2. calcCompileWarnings(String compilerResult)
  3. cleanUpEmptyLinesAndIndent(String input)
  4. common(Scanner in)
  5. computeSumTable(Scanner in, short n)
  6. confirm(String message)
  7. confirm(String message)