自学内容网 自学内容网

如何引起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();
        }

    }
}

结果:


原文地址:https://blog.csdn.net/m0_74042991/article/details/143038525

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!