[ BUG ? ] simple code throws on Windows but works fine on *nix
Daniel Fuchs
daniel.fuchs at oracle.com
Tue Jul 2 08:36:02 UTC 2019
Hi Sergey,
On 02/07/2019 10:25, Сергей Цыпанов wrote:
> Hello,
>
> 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
windows.
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.
best regards,
-- daniel
>
> Regards,
> Sergey Tsypanov
More information about the core-libs-dev
mailing list