Is Path object equals to DirectoryEntry object?
Rajendra Gutupalli
Rajendra.Gutupalli at Sun.COM
Mon Aug 4 02:58:50 PDT 2008
Hi Alan,
I noticed path.equals(directory entry object) returning true when path
and directory entry objects represents same file.
Please see the following code where c:\\testfolder contains only one
file ie. 'onefile'. Could you please let me know whether the observed
behavior satisfies the spec
where it says "If the given object is not a Path, or is a Path
associated with a different provider, then this method immediately
returns false.".
import java.nio.file.*;
public class TestEquals {
public static void main(String... args) throws Exception{
final Path path = Paths.get("c:\\testfolder\\onefile");
Path start = Paths.get("c:\\testfolder");
DirectoryStream ds = start.newDirectoryStream("*");
for (DirectoryEntry de :ds){
System.out.println("Path object ~ DirectoryEntry object ->"
+path.equals(de));
}
}
}
when run:
Path object ~ DirectoryEntry object ->true
Thanks
Rajendra.
More information about the nio-dev
mailing list