简体   繁体   English

在Java中对资源进行尝试

[英]Using try with resources in Java

当我在用Java 8 文档编写的程序中尝试使用资源时,仍然有必要还是一种好的做法来明确地关闭文件?

From the documentation you linked: "Note: A try-with-resources statement can have catch and finally blocks just like an ordinary try statement. In a try-with-resources statement, any catch or finally block is run after the resources declared have been closed ." 从您链接的文档中:“注意:try-with-resources语句可以具有catch和finally块,就像普通的try语句一样。在try-with-resources语句中,任何catch或finally块都在声明的资源拥有之后运行已关闭 。”

So, no. 所以不行。 You don't need to. 不用了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM