我将在目录中拥有大量文件.我将使用文件名File.getName()并将其记录到日志文件中.我认为,我不需要关闭文件,因为我没有在其中进行任何读/写操作.
它是否正确?
Only resources needed to be close.
Run Code Online (Sandbox Code Playgroud)
在Java API中有一个接口可关闭接口,这些类实现了这个接口,它们需要在使用后关闭.
close() //method is in that interface..
Run Code Online (Sandbox Code Playgroud)
并且使用close是
It closes the stream and releases any system resources associated with it.
If the stream is already closed then invoking this method has no effect.
Run Code Online (Sandbox Code Playgroud)
File 没有必要亲近