如何在try语句中使用资源文件和内存
原文英文,约300词,阅读约需2分钟。发表于: 。I wrote a small piece of code to do some pdf encryption with openpdf, and intellij's sonarlint was complaining about “Resources should be closed” more details here non compliant example...
作者编写了使用OpenPDF对PDF加密的代码。初始代码未关闭资源,SonarLint发出警告。改进后,使用try-with-resources语句确保资源正确关闭,成功创建了受密码保护的PDF。