Assuming 'parentDirectory' exists but 'myFile.txt' does not,

     FileUtils.writeStringToFile( new File( "parentDirectory", "myFile.txt"
), "Foo bar", "UTF-8" );

works just fine; it creates 'myFile.txt' in 'parentDirectory'.  However, if
'childDirectory' does not exist,

     FileUtils.writeStringToFile( new File(
"parentDirectory/childDirectory", "myFile.txt" ), "Foo bar", "UTF-8" );

throws a FileNotFoundException because 'myFile.txt' cannot be opened in the
non-existent 'childDirectory'.  The JavaDoc for writeStringToFile() says:
"Writes a String to a file creating the file if it does not exist."  That
seems to imply that directories would be created, if need be; however, that
is not happening.  Is this a bug?  Or does the documentation just need to be
clarified?

Thanks.

--
Jamie Bisotti

Reply via email to