java.nio.file.Files 和 java.io.File 的区别?

Difference between java.nio.file.Files and java.io.File?

Files 相对于 File 的优势或主要特点是什么?什么时候选择一个?为什么?

编辑:这只是我们世界中的另一个 'difference between' 问题 - 所以请确保您真的想投反对票!

Files:

This class consists exclusively of static methods that operate on files, directories, or other types of files.

但是文件是文件和目录路径名的抽象表示

意味着 文件 class 是一个实用程序 class 可以对文件执行操作。

根据 Java 文档,java.nio.file.Files class consists exclusively of static methods that operate on files, directories, or other types of files. In most cases, the methods defined here will delegate to the associated file system provider to perform the file operations.

java.io.File is an abstract representation of file and directory pathnames.