Path.equals(Object other) has the following syntax.
boolean equals(Object other)
In the following code shows how to use Path.equals(Object other) method.
import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; /*from w w w . ja va 2 s . c o m*/ public class Main { public static void main(String[] args) { Path path01 = Paths.get("/tutorial/Java/JavaFX/Topic.txt"); Path path02 = Paths.get("C:/tutorial/Java/JavaFX/Topic.txt"); //compare using Path.equals if (path01.equals(path02)) { System.out.println("The paths are equal!"); } else { System.out.println("The paths are not equal!"); } } }
The code above generates the following result.