public static class FileWriterWithEncoding.Builder extends AbstractStreamBuilder<FileWriterWithEncoding,FileWriterWithEncoding.Builder>
FileWriterWithEncoding.
Using a CharsetEncoder:
FileWriterWithEncoding w = FileWriterWithEncoding.builder()
.setPath(path)
.setAppend(false)
.setCharsetEncoder(StandardCharsets.UTF_8.newEncoder())
.get();
Using a Charset:
FileWriterWithEncoding w = FileWriterWithEncoding.builder()
.setPath(path)
.setAppend(false)
.setCharsetEncoder(StandardCharsets.UTF_8)
.get();
get()| Modifier and Type | Field and Description |
|---|---|
private boolean |
append |
private java.nio.charset.CharsetEncoder |
charsetEncoder |
| Constructor and Description |
|---|
Builder() |
| Modifier and Type | Method and Description |
|---|---|
FileWriterWithEncoding |
get()
Builds a new
FileWriterWithEncoding. |
FileWriterWithEncoding.Builder |
setAppend(boolean append)
Sets whether or not to append.
|
FileWriterWithEncoding.Builder |
setCharsetEncoder(java.nio.charset.CharsetEncoder charsetEncoder)
Sets charsetEncoder to use for encoding.
|
getBufferSize, getBufferSizeDefault, getCharSequence, getCharset, getCharsetDefault, getInputStream, getOpenOptions, getOutputStream, getPath, getReader, getWriter, setBufferSize, setBufferSize, setBufferSizeChecker, setBufferSizeDefault, setBufferSizeMax, setCharset, setCharset, setCharsetDefault, setOpenOptionscheckOrigin, getOrigin, hasOrigin, newByteArrayOrigin, newCharSequenceOrigin, newFileOrigin, newFileOrigin, newInputStreamOrigin, newOutputStreamOrigin, newPathOrigin, newPathOrigin, newReaderOrigin, newURIOrigin, newWriterOrigin, setByteArray, setCharSequence, setFile, setFile, setInputStream, setOrigin, setOutputStream, setPath, setPath, setReader, setURI, setWriterasThisclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitasSupplierprivate boolean append
private java.nio.charset.CharsetEncoder charsetEncoder
public FileWriterWithEncoding get() throws java.io.IOException
FileWriterWithEncoding.
You must set input that supports File on this builder, otherwise, this method throws an exception.
This builder use the following aspects:
FileCharsetEncoderjava.lang.UnsupportedOperationException - if the origin cannot provide a File.java.lang.IllegalStateException - if the origin is null.java.io.IOException - if an I/O error occurs.AbstractOrigin.getFile()public FileWriterWithEncoding.Builder setAppend(boolean append)
append - Whether or not to append.public FileWriterWithEncoding.Builder setCharsetEncoder(java.nio.charset.CharsetEncoder charsetEncoder)
charsetEncoder - The charsetEncoder to use for encoding.