How to check whether an OutputStream is closed

后端 未结 7 1205
南笙
南笙 2020-12-10 10:29

Is there anyway to check whether an OutputStream is closed without attempting to write to it and catching the IOException?

For example, consider the fol

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-10 11:16

    by using out.checkError()

    while(!System.out.checkError()) {
        System.out.println('hi');
    }
    

    found it here: How do I get java to exit when piped to head

提交回复
热议问题