groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kee...@apache.org
Subject incubator-groovy git commit: GROOVY-7553: Path.write() appends when encoding parameter present (closes #89)
Date Thu, 20 Aug 2015 01:10:27 GMT
Repository: incubator-groovy
Updated Branches:
  refs/heads/master 1f50866cc -> ab9a8f226


GROOVY-7553: Path.write() appends when encoding parameter present (closes #89)


Project: http://git-wip-us.apache.org/repos/asf/incubator-groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-groovy/commit/ab9a8f22
Tree: http://git-wip-us.apache.org/repos/asf/incubator-groovy/tree/ab9a8f22
Diff: http://git-wip-us.apache.org/repos/asf/incubator-groovy/diff/ab9a8f22

Branch: refs/heads/master
Commit: ab9a8f22637d3805a96008063b1dc6c533c2b001
Parents: 1f50866
Author: Keegan Witt <keeganwitt@gmail.com>
Authored: Wed Aug 19 11:17:31 2015 -0400
Committer: Keegan Witt <keeganwitt@gmail.com>
Committed: Wed Aug 19 21:09:18 2015 -0400

----------------------------------------------------------------------
 .../org/codehaus/groovy/runtime/NioGroovyMethods.java    |  2 +-
 .../codehaus/groovy/runtime/NioGroovyMethodsTest.groovy  | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/ab9a8f22/subprojects/groovy-nio/src/main/java/org/codehaus/groovy/runtime/NioGroovyMethods.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-nio/src/main/java/org/codehaus/groovy/runtime/NioGroovyMethods.java
b/subprojects/groovy-nio/src/main/java/org/codehaus/groovy/runtime/NioGroovyMethods.java
index 029084d..8c9271f 100644
--- a/subprojects/groovy-nio/src/main/java/org/codehaus/groovy/runtime/NioGroovyMethods.java
+++ b/subprojects/groovy-nio/src/main/java/org/codehaus/groovy/runtime/NioGroovyMethods.java
@@ -559,7 +559,7 @@ public class NioGroovyMethods extends DefaultGroovyMethodsSupport {
     public static void write(Path self, String text, String charset) throws IOException {
         Writer writer = null;
         try {
-            writer = new OutputStreamWriter(Files.newOutputStream(self, CREATE, APPEND),
Charset.forName(charset));
+            writer = new OutputStreamWriter(Files.newOutputStream(self), Charset.forName(charset));
             writer.write(text);
             writer.flush();
 

http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/ab9a8f22/subprojects/groovy-nio/src/test/groovy/org/codehaus/groovy/runtime/NioGroovyMethodsTest.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-nio/src/test/groovy/org/codehaus/groovy/runtime/NioGroovyMethodsTest.groovy
b/subprojects/groovy-nio/src/test/groovy/org/codehaus/groovy/runtime/NioGroovyMethodsTest.groovy
index fe01a0e..7ec7d36 100644
--- a/subprojects/groovy-nio/src/test/groovy/org/codehaus/groovy/runtime/NioGroovyMethodsTest.groovy
+++ b/subprojects/groovy-nio/src/test/groovy/org/codehaus/groovy/runtime/NioGroovyMethodsTest.groovy
@@ -168,6 +168,17 @@ class NioGroovyMethodsTest extends Specification {
         file.text == 'Hello world!'
     }
 
+    def testWriteWithEncoding()  {
+        when:
+        def str = 'Hello world!'
+        def file = temporaryFolder.newFile()
+        file.toPath().write('Ciao mundo!')
+        file.toPath().write(str, 'UTF-8')
+
+        then:
+        file.text == str
+    }
+
     def testAppendObject() {
         setup:
         def file = temporaryFolder.newFile()


Mime
View raw message