在finally块中清理资源或者使用try-with-resource语句。

答案解析

推荐用try-with-resource自动管理资源,减少手动finally代码,保证资源安全释放。