java.io.File 为什么没有对应的close方法?


https://stackoverflow.com/questions/4752266/why-java-io-file-doesnt-have-a-close-method

File is only a representation of a pathname, with a few methods concerning the filesystem (like exists()) and directory handling but actual streaming input and output is done elsewhere. Streams can be opened and closed, files cannot.

Java.io.File 只是一个路径表示层,如果需要进行操作,需要调用文件流(file stream),只要文件流关闭就可以。