其他分享
首页 > 其他分享> > Sonar常见问题

Sonar常见问题

作者:互联网

Use try-with-resources or close this "BufferedOutputStream" in a "finally" clause.

参考:https://blog.csdn.net/libusi001/article/details/103848922

如果出现异常会跳转到catch,那么out.close()就不会执行。

所以需要在“ finally”子句中关闭此“ BufferedOutputStream”。

BufferedOutputStream需要写在try外面才行,而且必须初始化,初始化为null。

这样又会报空指针异常,所以需要判空

标签:初始化,常见问题,try,finally,需要,BufferedOutputStream,Sonar,close
来源: https://www.cnblogs.com/Uni-Hoang/p/15421101.html