Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Incomplete
-
2.4
-
None
-
None
Description
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:
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); }
If it doesn't exist, it will just try to create a FileOutputStream, which throws a FileNotFoundException.