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
Sat Dec 6 12:44:05 UTC 2014


On Sat, Dec 6, 2014 at 1:07 PM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
[...]
> It's not prohibited by the spec because directories can be opened as regular
> files on some platforms. So what you are seeing it just platform specific
> behavio[r].
>

OK... By the way, on Windows system the code I posted (with a correct
path, of course) throws AccessDeniedException when attempting to open!

I do believe that a IsDirectoryException should be created for such
cases (as an "optional specific exception" as the documentation says).

-- 
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