You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2019/07/14 18:03:12 UTC

[ant] branch master updated: use Files API rather than FileWriter

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

bodewig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git


The following commit(s) were added to refs/heads/master by this push:
     new e3eb039  use Files API rather than FileWriter
e3eb039 is described below

commit e3eb039ab638735390b3eff361ae06654f95b03c
Author: Stefan Bodewig <bo...@apache.org>
AuthorDate: Sun Jul 14 20:02:32 2019 +0200

    use Files API rather than FileWriter
---
 src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
index f096a49..3a87879 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
@@ -23,13 +23,13 @@ import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.StringReader;
 import java.nio.file.Files;
+import java.nio.file.StandardOpenOption;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
@@ -482,7 +482,8 @@ public class SSHExec extends SSHBase {
      */
     private void writeToFile(final String from, final boolean append, final File to)
         throws IOException {
-        try (BufferedWriter out = new BufferedWriter(new FileWriter(to.getAbsolutePath(), append))) {
+        try (BufferedWriter out = Files.newBufferedWriter(to.getAbsoluteFile().toPath(),
+            StandardOpenOption.APPEND)) {
             final StringReader in = new StringReader(from);
             final char[] buffer = new char[BUFFER_SIZE];
             while (true) {