diff --git a/aksw-commons-io-parent/aksw-commons-io-utils/src/main/java/org/aksw/commons/io/util/FileUtils.java b/aksw-commons-io-parent/aksw-commons-io-utils/src/main/java/org/aksw/commons/io/util/FileUtils.java index e0fb2684..27a8de1b 100644 --- a/aksw-commons-io-parent/aksw-commons-io-utils/src/main/java/org/aksw/commons/io/util/FileUtils.java +++ b/aksw-commons-io-parent/aksw-commons-io-utils/src/main/java/org/aksw/commons/io/util/FileUtils.java @@ -42,7 +42,11 @@ public static OutputStream newOutputStream(OutputConfig config) throws IOExcepti result = StdIo.openStdOutWithCloseShield(); } else { Path path = Path.of(fileName); - result = Files.newOutputStream(path, allowOverwrite ? StandardOpenOption.CREATE : StandardOpenOption.CREATE_NEW); + if (allowOverwrite) { + result = Files.newOutputStream(path, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); + } else { + result = Files.newOutputStream(path, StandardOpenOption.CREATE_NEW); + } } return result;