What does scanner.close() do?
Yes, it does mean that System.in will be closed. Test case: import java.util.*; public class CloseScanner { public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(System.in); scanner.close(); System.in.read(); } } This code terminates with $ java CloseScanner Exception in thread “main” java.io.IOException: Stream closed at java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:162) at java.io.BufferedInputStream.fill(BufferedInputStream.java:206) at java.io.BufferedInputStream.read(BufferedInputStream.java:254) at … Read more