I could not understand how java.nio.file.Files.isSameFile method is different from java.nio.file.Path.equals method.
Could anybody please tell how they are different?
equal() == true
then isSameFile() == true
isSameFile() == true
, equal()
is not always true
The isSameFile()
method first checks if the Path
objects are equal in terms of equal()
, and if so, it automatically returns true without checking to see if either file exists.
If the Path
object equals()
comparison returns false, then it locates each file to which the path refers in the file system and determines if they are the same, throwing a checked IOException
if either file does not exist.