在程序中使用如下代码是否是安全的
properties.load(new FileInputStream("src/main/resource/jdbc.properties"));
直接 new 对象的形式作为方法参数传递,当 load 方法执行完后,作为方法参数的 FileInputStream 并没有办法显示的关闭,这种等待对象超出作用域等待自动释放的方法是否是安全的?
认证0级讲师
Safety is safe, but this way of using resources is not recommended. Unused resources should be released immediately.
It has nothing to do with security. If you don’t close it after use, it will cause a lot of memory garbage. Although Java will automatically collect it, it will overall increase the burden on the system
Safety is safe, but this way of using resources is not recommended. Unused resources should be released immediately.
It has nothing to do with security. If you don’t close it after use, it will cause a lot of memory garbage. Although Java will automatically collect it, it will overall increase the burden on the system