Stream closed and not reopened - Java

后端 未结 2 859
一个人的身影
一个人的身影 2021-01-24 02:50

I have an easy \'homework\' to do, but I have found a little problem with the closure of the input stream. To put it simply, I have to make a contact \'list\' application in Jav

2条回答
  •  执念已碎
    2021-01-24 03:40

    Your problem is indeed due to the try-with-resource statement that closes new InputStreamReader(System.in) which behind the scene closes also the underlying input stream that is System.in (in is a public static field of System) such that in your modify method System.in is already closed and then cannot be read anymore this is why you get this exception.

提交回复
热议问题