首页 > 编程知识 正文

java按钮关闭当前窗口,java关闭程序的代码

时间:2023-05-03 05:08:09 阅读:110105 作者:1149

这看起来几乎很傻,关闭OutputStream时最可靠的模式是什么? 现在我有以下try-catch-finally-overkill这样的东西。

专用流内容文件(output stream ostream,Properties contents ) )。

try {

contents.store(ostream,' comments ' );

}

catch(ioexceptione

thrownewresourceexception (' failedtowritecontents ',e );

}

法利{

try {

ostream.close (;

}

catch(ioexceptione ) { /* what can be done here anyway? () ) }

}

}

为什么会抛出被检查的异常对我来说仍然是个谜。 虽然可以创建一个关闭/捕获块的封闭方法,但是如果其中已经有类似file util.closefileandthrowuncheckedexception ()的内容,则希望使用它悲伤的时候有很多小项目,有很多开发者的时候会有帮助; 是正确的方法。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。