确定两个文件名路径是否引用同一个文件
/*来自 N o w J a v a . c o m*/ import java.awt.Graphics; import java.io.File; import java.io.IOException; public class Main { public void m() { File file1 = new File("./filename"); File file2 = new File("filename"); // Filename paths are not equal boolean b = file1.equals(file2); // false // Normalize the paths try { file1 = file1.getCanonicalFile(); // c:\folder\filename file2 = file2.getCanonicalFile(); // c:\folder\filename /* from n o w j a v a . c o m - 时 代 Java*/ }