kinow commented on pull request #296:
URL: https://github.com/apache/commons-io/pull/296#issuecomment-958427374


   @wodencafe I was curious, and tried the following too before jumping to 
other PRs:
   
   ```diff
   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 3d7cfb27..7fbeee23 100644
   --- a/src/main/java/org/apache/commons/io/output/FileWriterWithEncoding.java
   +++ b/src/main/java/org/apache/commons/io/output/FileWriterWithEncoding.java
   @@ -46,10 +46,7 @@
     *
     * @since 1.4
     */
   -public class FileWriterWithEncoding extends Writer {
   -    // Cannot extend ProxyWriter, as requires writer to be
   -    // known when super() is called
   -
   +public class FileWriterWithEncoding extends ProxyWriter {
        /**
         * Initializes the wrapped file writer. Ensure that a cleanup occurs if 
the writer creation fails.
         *
   @@ -85,9 +82,6 @@ private static Writer initWriter(final File file, final 
Object encoding, final b
            }
        }
    
   -    /** The writer to decorate. */
   -    private final Writer out;
   -
        /**
         * Constructs a FileWriterWithEncoding with a file encoding.
         *
   @@ -110,7 +104,7 @@ public FileWriterWithEncoding(final File file, final 
Charset charset) throws IOE
         * @throws IOException in case of an I/O error.
         */
        public FileWriterWithEncoding(final File file, final Charset encoding, 
final boolean append) throws IOException {
   -        this.out = initWriter(file, encoding, append);
   +        super(initWriter(file, encoding, append));
        }
    
        /**
   @@ -135,7 +129,7 @@ public FileWriterWithEncoding(final File file, final 
CharsetEncoder charsetEncod
         * @throws IOException in case of an I/O error.
         */
        public FileWriterWithEncoding(final File file, final CharsetEncoder 
charsetEncoder, final boolean append) throws IOException {
   -        this.out = initWriter(file, charsetEncoder, append);
   +        super(initWriter(file, charsetEncoder, append));
        }
    
        /**
   @@ -160,7 +154,7 @@ public FileWriterWithEncoding(final File file, final 
String charsetName) throws
         * @throws IOException in case of an I/O error.
         */
        public FileWriterWithEncoding(final File file, final String 
charsetName, final boolean append) throws IOException {
   -        this.out = initWriter(file, charsetName, append);
   +        super(initWriter(file, charsetName, append));
        }
    
        /**
   ```
   
   I think it achieves something similar to what you are suggesting here, but 
without the extra internal class? I haven't tested it, and haven't worked on IO 
lately, so other committers would have to take a look at it too. But WDYT?
   
   Bruno


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to