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-io.git

commit cf139a3d1eae1ce5eb72222e530f4f18108c7eb0
Author: Gary Gregory <gardgreg...@gmail.com>
AuthorDate: Sun Jul 25 14:42:14 2021 -0400

    [IO-744] FileWriterWithEncoding for an existing file no longer truncates
    the file. #251.
    
    This commit is a much simpler fix than PR 251. The test from the PR is
    the same, just reformatted.
---
 .../org/apache/commons/io/output/FileWriterWithEncoding.java   | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/io/output/FileWriterWithEncoding.java 
b/src/main/java/org/apache/commons/io/output/FileWriterWithEncoding.java
index d3b9d3b..fa18289 100644
--- a/src/main/java/org/apache/commons/io/output/FileWriterWithEncoding.java
+++ b/src/main/java/org/apache/commons/io/output/FileWriterWithEncoding.java
@@ -221,20 +221,20 @@ public class FileWriterWithEncoding extends Writer {
      * @throws NullPointerException if the file or encoding is null
      * @throws IOException if an error occurs
      */
-     private static Writer initWriter(final File file, final Object encoding, 
final boolean append) throws IOException {
+    private static Writer initWriter(final File file, final Object encoding, 
final boolean append) throws IOException {
         Objects.requireNonNull(file, "file");
         Objects.requireNonNull(encoding, "encoding");
         OutputStream stream = null;
         final boolean fileExistedAlready = file.exists();
         try {
-            stream = Files.newOutputStream(file.toPath(),  append ? 
StandardOpenOption.APPEND : StandardOpenOption.CREATE, 
StandardOpenOption.TRUNCATE_EXISTING);
+            stream = Files.newOutputStream(file.toPath(), append ? 
StandardOpenOption.APPEND : StandardOpenOption.CREATE, 
StandardOpenOption.TRUNCATE_EXISTING);
             if (encoding instanceof Charset) {
-                return new OutputStreamWriter(stream, (Charset)encoding);
+                return new OutputStreamWriter(stream, (Charset) encoding);
             }
             if (encoding instanceof CharsetEncoder) {
-                return new OutputStreamWriter(stream, 
(CharsetEncoder)encoding);
+                return new OutputStreamWriter(stream, (CharsetEncoder) 
encoding);
             }
-            return new OutputStreamWriter(stream, (String)encoding);
+            return new OutputStreamWriter(stream, (String) encoding);
         } catch (final IOException | RuntimeException ex) {
             try {
                 IOUtils.close(stream);

Reply via email to