On 6/6/06, Lazarte, Ivan <[EMAIL PROTECTED]> wrote:

Personal pet peeve, I would love it if IO lib trusted the developer a bit
more.  It trusts you like 90% already, but i'd prefer 100 :)  A wrapper I
always write for any file lib is a "writeFileNoComplain" which takes any
file/directory combo and writes it completely making sure each part is unix
friendly.

This allows me to make up very sophisticated file backup/logging/caching
structures with ease, where I can just pass in locations like
"/data/<class_name>/<product>/<date|timestamp>/<arguments_concatenated>.cache"  
and
let the file lib do the work of saving it..

________________________________

From: Jamie Bisotti [mailto:[EMAIL PROTECTED]
Sent: Mon 6/5/2006 1:29 PM
To: Jakarta Commons Users List
Subject: [IO] writeStringToFile( File, String, String ), when File does
not exist



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




So, is there anyone on this list that can/will provide a definitive answer
to my original question?  Should I be asking it elsewhere?  Thanks.

--
Jamie Bisotti

Reply via email to