检查两个路径是否是相同的文件/文件夹。
import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; /** 来自 时代Java公众号 - N o w J a v a . c o m**/ import java.nio.file.Paths; public class Main { public static void main(String[] args) { Path path01 = Paths.get("/folder1/folder2/folder3/test.txt"); Path path02 = Paths.get("C:/folder1/folder2/folder3/test.txt"); // compare using Files.isSameFile try { boolean check = Files.isSameFile(path01, path02); if (check) {/**from nowjava - 时代Java**/ System.out.println("The paths locate the same file!"); } else { System.o