Closing BufferedReader and System.in

送分小仙女□ 提交于 2019-11-26 19:11:51

Looks like you need:

http://commons.apache.org/io/apidocs/org/apache/commons/io/input/CloseShieldInputStream.html

Wrap that around System.in before making your reader, and then all will be well, since you won't do that when you are using a FileInputStream.

kindlee

If you just want to get input from keyboard by System.in, please use static BufferedReader wrapping InputStreamReader (also wrapping System.in). Like this:

 Public BufferedReader is = new BufferedReader(new InputStreamReader(System.in));

And is.close(); would be needed right before your application terminated.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!