Fixed error in FileUtils when creating a new File with append = true.

In this case FileUtils throws a FileCreationException if the path for
the new file doesn't already exist, because it doesn't try to create the
path.

TestCase appendend to FileUtilsTests
testCreateDirectoryStructureAppendMode checks that a path is creaded if
append is true
This commit is contained in:
Veit Hoffmann
2013-08-05 17:58:11 +02:00
committed by Michael Minella
parent 3ea8d3ed65
commit 7c9396da18
2 changed files with 26 additions and 0 deletions

View File

@@ -74,6 +74,9 @@ public final class FileUtils {
}
else {
if (!file.exists()) {
if (file.getParent() != null) {
new File(file.getParent()).mkdirs();
}
if (!createNewFile(file)) {
throw new ItemStreamException("Output file was not created: [" + file.getAbsolutePath()
+ "]");