What happens to a BufferedReader that doesn't get closed within a callable.call?

后端 未结 5 732
后悔当初
后悔当初 2021-02-04 14:47

I have three questions.

To explain, I was reviewing someone\'s code, and noticed BufferedReaders sometimes aren\'t being closed. Usually, Eclipse gives a w

5条回答
  •  -上瘾入骨i
    2021-02-04 15:39

    You may not want to close the BufferedReader in this case. The InputStream which was passed to the constructor is the object that may be associated with a system resource. The BufferedReader and the InputStreamReader are just wrappers around that. Closing the BufferedReader would also close the InputStream, which may not be what the caller wanted.

提交回复
热议问题