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

后端 未结 7 2081
醉酒成梦
醉酒成梦 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:14

    No, the topmost level Stream or reader will ensure that all underlying streams / readers are closed.

    Check the close() method implementation of your topmost level stream.

提交回复
热议问题