[ BUG ? ] simple code throws on Windows but works fine on *nix
daniel.fuchs at oracle.com
Tue Jul 2 08:36:02 UTC 2019
On 02/07/2019 10:25, Сергей Цыпанов wrote:
> this is exactly how I've worked this around.
> But shouldn't behaviour be the same on all platforms
> at least when accessing files on a local drive?
Hierarchical URLs/URIs are specified to use '/' as file separator
This is platform independent.
On the other hand file systems are platform dependents:
the file system file separator is '/' on UNIX and '\' on
Therefore converting a URL path to a String and then feeding
it to the file system without any validation/conversion is a bug
in your code. As Alan mentioned, an URL path is not a file path
even if it looks like it.
Using Path.of(URI) is the right API, and not a work around.
> Sergey Tsypanov
More information about the core-libs-dev