Do I have to close FileOutputStream which is wrapped by PrintStream?

前端 未结 5 1746
醉话见心
醉话见心 2020-12-05 07:43

I\'m using FileOutputStream with PrintStream like this:

class PrintStreamDemo {  
    public static void main(String args[]) { 
            


        
5条回答
  •  广开言路
    2020-12-05 08:12

    No you dont need to. PrintStream.close method automatically closes the underlining output stream.

    Check the API.

    http://download.oracle.com/javase/6/docs/api/java/io/PrintStream.html#close%28%29

提交回复
热议问题