Is it necessary to close each nested OutputStream and Writer separately?

后端 未结 7 2065
醉酒成梦
醉酒成梦 2020-11-28 02:28

I am writing a piece of code:

OutputStream outputStream = new FileOutputStream(createdFile);
GZIPOutputStream gzipOutputStream = new GZIPOutputStream(outputS         


        
7条回答
  •  自闭症患者
    2020-11-28 03:20

    It will be fine if you only close the last stream - the close call will be send to the underlying streams, too.

提交回复
热议问题