几天前,我意识到PrintWriter(以及PrintStream)在写,刷新或关闭时都不会抛出IOException.
相反,它会trouble=true在发生错误时设置内部标志(). 它不可能得到确切的异常,但只有在有一些异常时才会出现(checkError()).
trouble=true
我的问题是:为什么会有这样的行为?API设计不是那么糟糕吗?
java api exception
api ×1
exception ×1
java ×1