Java examples for File Path IO:Path
Determining If Two Filename Paths Refer to the Same File
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 {/*from ww w. ja v a2 s . co m*/ file1 = file1.getCanonicalFile(); // c:\folder\filename file2 = file2.getCanonicalFile(); // c:\folder\filename } catch (IOException e) { } // Filename paths are now equal b = file1.equals(file2); // true } }