-
Notifications
You must be signed in to change notification settings - Fork 282
Closed
Labels
Milestone
Description
The default file system provider returns URI's with trailing slashes if the URI is known to refer to a directory. This only way to know for sure if a URI refers to a directory or a file is if the directory actually exists on disk. For example:
Path rootPath = Paths.get(URI.create("file:/"));
System.out.println(rootPath.toUri());
Path dir1 = rootPath.resolve("dir1");
System.out.println(dir1.toUri());
Path dir1Path = Files.createDirectory(dir1);
System.out.println(dir1.toUri());
System.out.println(dir1Path.toUri());
If C:\dir1\ does not exist before running this code, the result will be:
file:///C:/
file:///C:/dir1
file:///C:/dir1/
file:///C:/dir1/
Notice that dir1.toUri() does not contain a trailing slash before the directory is created, but it does contain a trailing slash afterward.
I have verified this same behavior on OSX as well.