public class FileWriterWithEncoding extends ProxyWriter
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, see FileWriterWithEncoding.Builder.
| Modifier and Type | Class and Description |
|---|---|
static class |
FileWriterWithEncoding.Builder
Builds a new
FileWriterWithEncoding instance. |
out| Constructor and Description |
|---|
FileWriterWithEncoding(File file,
Charset charset)
Deprecated.
|
FileWriterWithEncoding(File file,
Charset encoding,
boolean append)
Deprecated.
|
FileWriterWithEncoding(File file,
CharsetEncoder charsetEncoder)
Deprecated.
|
FileWriterWithEncoding(File file,
CharsetEncoder charsetEncoder,
boolean append)
Deprecated.
|
FileWriterWithEncoding(File file,
String charsetName)
Deprecated.
|
FileWriterWithEncoding(File file,
String charsetName,
boolean append)
Deprecated.
|
FileWriterWithEncoding(String fileName,
Charset charset)
Deprecated.
|
FileWriterWithEncoding(String fileName,
Charset charset,
boolean append)
Deprecated.
|
FileWriterWithEncoding(String fileName,
CharsetEncoder encoding)
Deprecated.
|
FileWriterWithEncoding(String fileName,
CharsetEncoder charsetEncoder,
boolean append)
Deprecated.
|
FileWriterWithEncoding(String fileName,
String charsetName)
Deprecated.
|
FileWriterWithEncoding(String fileName,
String charsetName,
boolean append)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
static FileWriterWithEncoding.Builder |
builder()
Constructs a new
FileWriterWithEncoding.Builder. |
afterWrite, append, append, append, beforeWrite, close, flush, handleIOException, write, write, write, write, write@Deprecated public FileWriterWithEncoding(File file, Charset charset) throws IOException
builder(), FileWriterWithEncoding.Builder, and FileWriterWithEncoding.Builder.get()file - the file to write to, not nullcharset - the encoding to use, not nullNullPointerException - if the file or encoding is nullIOException - in case of an I/O error@Deprecated public FileWriterWithEncoding(File file, Charset encoding, boolean append) throws IOException
builder(), FileWriterWithEncoding.Builder, and FileWriterWithEncoding.Builder.get()file - the file to write to, not null.encoding - the name of the requested charset, null uses the default Charset.append - true if content should be appended, false to overwrite.NullPointerException - if the file is null.IOException - in case of an I/O error.@Deprecated public FileWriterWithEncoding(File file, CharsetEncoder charsetEncoder) throws IOException
builder(), FileWriterWithEncoding.Builder, and FileWriterWithEncoding.Builder.get()file - the file to write to, not nullcharsetEncoder - the encoding to use, not nullNullPointerException - if the file or encoding is nullIOException - in case of an I/O error@Deprecated public FileWriterWithEncoding(File file, CharsetEncoder charsetEncoder, boolean append) throws IOException
builder(), FileWriterWithEncoding.Builder, and FileWriterWithEncoding.Builder.get()file - the file to write to, not null.charsetEncoder - the encoding to use, null uses the default Charset.append - true if content should be appended, false to overwrite.NullPointerException - if the file is null.IOException - in case of an I/O error.@Deprecated public FileWriterWithEncoding(File file, String charsetName) throws IOException
builder(), FileWriterWithEncoding.Builder, and FileWriterWithEncoding.Builder.get()file - the file to write to, not nullcharsetName - the name of the requested charset, not nullNullPointerException - if the file or encoding is nullIOException - in case of an I/O error@Deprecated public FileWriterWithEncoding(File file, String charsetName, boolean append) throws IOException
builder(), FileWriterWithEncoding.Builder, and FileWriterWithEncoding.Builder.get()file - the file to write to, not null.charsetName - the name of the requested charset, null uses the default Charset.append - true if content should be appended, false to overwrite.NullPointerException - if the file is null.IOException - in case of an I/O error.@Deprecated public FileWriterWithEncoding(String fileName, Charset charset) throws IOException
builder(), FileWriterWithEncoding.Builder, and FileWriterWithEncoding.Builder.get()fileName - the name of the file to write to, not nullcharset - the charset to use, not nullNullPointerException - if the file name or encoding is nullIOException - in case of an I/O error@Deprecated public FileWriterWithEncoding(String fileName, Charset charset, boolean append) throws IOException
builder(), FileWriterWithEncoding.Builder, and FileWriterWithEncoding.Builder.get()fileName - the name of the file to write to, not nullcharset - the encoding to use, not nullappend - true if content should be appended, false to overwriteNullPointerException - if the file name or encoding is nullIOException - in case of an I/O error@Deprecated public FileWriterWithEncoding(String fileName, CharsetEncoder encoding) throws IOException
builder(), FileWriterWithEncoding.Builder, and FileWriterWithEncoding.Builder.get()fileName - the name of the file to write to, not nullencoding - the encoding to use, not nullNullPointerException - if the file name or encoding is nullIOException - in case of an I/O error@Deprecated public FileWriterWithEncoding(String fileName, CharsetEncoder charsetEncoder, boolean append) throws IOException
builder(), FileWriterWithEncoding.Builder, and FileWriterWithEncoding.Builder.get()fileName - the name of the file to write to, not nullcharsetEncoder - the encoding to use, not nullappend - true if content should be appended, false to overwriteNullPointerException - if the file name or encoding is nullIOException - in case of an I/O error@Deprecated public FileWriterWithEncoding(String fileName, String charsetName) throws IOException
builder(), FileWriterWithEncoding.Builder, and FileWriterWithEncoding.Builder.get()fileName - the name of the file to write to, not nullcharsetName - the name of the requested charset, not nullNullPointerException - if the file name or encoding is nullIOException - in case of an I/O error@Deprecated public FileWriterWithEncoding(String fileName, String charsetName, boolean append) throws IOException
builder(), FileWriterWithEncoding.Builder, and FileWriterWithEncoding.Builder.get()fileName - the name of the file to write to, not nullcharsetName - the name of the requested charset, not nullappend - true if content should be appended, false to overwriteNullPointerException - if the file name or encoding is nullIOException - in case of an I/O errorpublic static FileWriterWithEncoding.Builder builder()
FileWriterWithEncoding.Builder.FileWriterWithEncoding.Builder.Copyright © 2002–2023 The Apache Software Foundation. All rights reserved.