You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/06/23 20:27:13 UTC

[commons-vfs] 06/15: [local] Throw a specialized RuntimeException instead of RuntimeException

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git

commit f0ab7c1e98da801913d6d6a8458483804be09067
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jun 23 16:24:59 2023 -0400

    [local] Throw a specialized RuntimeException instead of
    RuntimeException
---
 .../java/org/apache/commons/vfs2/provider/local/LocalFile.java | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFile.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFile.java
index dc607753..e2c28298 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFile.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFile.java
@@ -25,6 +25,7 @@ import java.nio.file.Files;
 import java.nio.file.OpenOption;
 import java.nio.file.StandardOpenOption;
 
+import org.apache.commons.io.file.PathUtils;
 import org.apache.commons.vfs2.FileObject;
 import org.apache.commons.vfs2.FileSystemException;
 import org.apache.commons.vfs2.FileType;
@@ -124,13 +125,8 @@ public class LocalFile extends AbstractFileObject<LocalFileSystem> {
      * Creates an output stream to write the file content to.
      */
     @Override
-    protected OutputStream doGetOutputStream(final boolean append) throws Exception {
-        // TODO Reuse Apache Commons IO
-        // @formatter:off
-        return Files.newOutputStream(file.toPath(), append ?
-            new OpenOption[] {StandardOpenOption.CREATE, StandardOpenOption.APPEND} :
-            new OpenOption[] {StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING});
-        // @formatter:on
+    protected OutputStream doGetOutputStream(final boolean append) throws IOException {
+        return PathUtils.newOutputStream(file.toPath(), append);
     }
 
     @Override