[ 
https://issues.apache.org/jira/browse/IO-472?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Pascal Schumacher closed IO-472.
--------------------------------
    Resolution: Incomplete

> FileUtils.openOutputStream doesn't create file if it doesn't exist
> ------------------------------------------------------------------
>
>                 Key: IO-472
>                 URL: https://issues.apache.org/jira/browse/IO-472
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 2.4
>            Reporter: David M. Karr
>
> The javadoc for this method has a pretty unambiguous statement: "The file 
> will be created if it does not exist."  However, this isn't happening.  The 
> code is pretty clear on this:
> {code:java}
> public static FileOutputStream openOutputStream(File file, boolean append) 
> throws IOException {
>         if (file.exists()) {
>             if (file.isDirectory()) {
>                 throw new IOException("File '" + file + "' exists but is a 
> directory");
>             }
>             if (file.canWrite() == false) {
>                 throw new IOException("File '" + file + "' cannot be written 
> to");
>             }
>         } else {
>             File parent = file.getParentFile();
>             if (parent != null) {
>                 if (!parent.mkdirs() && !parent.isDirectory()) {
>                     throw new IOException("Directory '" + parent + "' could 
> not be created");
>                 }
>             }
>         }
>         return new FileOutputStream(file, append);
>     }
> {code}
> If it doesn't exist, it will just try to create a FileOutputStream, which 
> throws a FileNotFoundException.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to