Path.createFile() and createDirectory() and nonexistent parents

Alan Bateman Alan.Bateman at Sun.COM
Thu Oct 22 04:29:40 PDT 2009

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 


More information about the nio-dev mailing list