Path.createFile() and createDirectory() and nonexistent parents
Joel Uckelman
uckelman at nomic.net
Thu Oct 22 05:22:32 PDT 2009
Thus spake Alan Bateman:
> Joel Uckelman wrote:
> > I can't tell from the Javadoc for Path.createFile() and createDirectory()
> > what the expected behavior is if some element in the path (other than
> > the name) doesn't exist. For example, if my Path is /foo/bar, but /foo
> > doesn't exist, will calling Path.createFile() also create the directory
> > /foo or will it throw an IOException? The docs appear to leave this open;
> > it would be nice if they made a clear statement one way or the other,
> > since the current state makes it hard to know how to handle failure.
> >
> No, these methods do not create any missing parent directories (has
> cannot do so as they are created to be atomic). However, point taken
> this isn't as clear as it should - there is a specification bug tracking
> this:
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6876000
>
That was my suscipcion (given also the existence of Files.createDirectories(),
which would have no point otherwsie). Thanks for clearing that up and filing
the bug report.
--
J.
More information about the nio-dev
mailing list