Bug or not bug? Files.newInputStream() on a Path which is a directory does not fail until you read from it
Francis Galiegue
fgaliegue at gmail.com
Sun Dec 7 09:21:20 UTC 2014
[...]>> :
>> OK... By the way, on Windows system the code I posted (with a correct
>> path, of course) throws AccessDeniedException when attempting to open!
>>
> Yes, Windows specific behavior where it fails with "Access Denied" when you
> attempt to open a directory.
>
Sorry, but I do not buy this argument at all.
The JRE is supposed to abstract the OS difference away from its user.
You know very well that on some OSes you cannot open a directory for
read, and you know how to detect that, so why don't you do the work
for the user here and throw an appropriate exception?
--
Francis Galiegue, fgaliegue at gmail.com, https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/parboiled1/grappa (redde
Caesaris: https://github.com/sirthias)
More information about the nio-dev
mailing list