如何引起Java中的System.in.read()函数的异常
演示的为:关闭标准输入流System.in后再调用System.in.read就会报出IOException
import java.io.IOException;
import java.io.InputStream;public class Test {public static void main(String[] args) {InputStream in = System.in;try {in.close();System.in.read();}catch (IOException e) {e.printStackTrace();}}
}
结果: