org.apache.commons.io.output

## Class FileWriterWithEncoding

- java.lang.Object
- - java.io.Writer
  - - java.io.FilterWriter
    - - org.apache.commons.io.output.ProxyWriter
      - - org.apache.commons.io.output.FileWriterWithEncoding

- All Implemented Interfaces:
    Closeable, Flushable, Appendable, AutoCloseable

      public class FileWriterWithEncoding
      extends ProxyWriter

  Writer of files that allows the encoding to be set.

  This class provides a simple alternative to `FileWriter` that allows an encoding to be set. Unfortunately, it cannot subclass `FileWriter`.

  By default, the file will be overwritten, but this may be changed to append.

  The encoding must be specified using either the name of the `Charset`, the `Charset`, or a `CharsetEncoder`. If the default encoding is required then use the `FileWriter` directly, rather than this implementation.

  To build an instance, use `FileWriterWithEncoding.Builder`.

  See Also:
    `FileWriterWithEncoding.Builder`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `FileWriterWithEncoding.Builder` Builds a new `FileWriterWithEncoding`.

  - ### Field Summary

    - ### Fields inherited from class java.io.FilterWriter

      `out`

    - ### Fields inherited from class java.io.Writer

      `lock`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static FileWriterWithEncoding.Builder` | `builder()` Constructs a new `FileWriterWithEncoding.Builder`.

    - ### Methods inherited from class org.apache.commons.io.output.ProxyWriter

      `afterWrite, append, append, append, beforeWrite, close, flush, handleIOException, write, write, write, write, write`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### builder

          public static FileWriterWithEncoding.Builder builder()

      Constructs a new `FileWriterWithEncoding.Builder`.
      Returns:
        Creates a new `FileWriterWithEncoding.Builder`.