public static class FileWriterWithEncoding.Builder extends AbstractStreamBuilder<FileWriterWithEncoding,FileWriterWithEncoding.Builder>
FileWriterWithEncoding
instance.
Using a CharsetEncoder:
FileWriterWithEncoding s = FileWriterWithEncoding.builder()
.setPath(path)
.setAppend(false)
.setCharsetEncoder(StandardCharsets.UTF_8.newEncoder())
.get();
Using a Charset:
FileWriterWithEncoding s = FileWriterWithEncoding.builder()
.setPath(path)
.setAppend(false)
.setCharsetEncoder(StandardCharsets.UTF_8)
.get();
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
FileWriterWithEncoding |
get()
Constructs a new instance.
|
FileWriterWithEncoding.Builder |
setAppend(boolean append)
Sets whether or not to append.
|
FileWriterWithEncoding.Builder |
setCharsetEncoder(CharsetEncoder charsetEncoder)
Sets charsetEncoder to use for encoding.
|
getBufferSize, getBufferSizeDefault, getCharSequence, getCharset, getCharsetDefault, getInputStream, getOpenOptions, getOutputStream, getPath, getWriter, setBufferSize, setBufferSize, setBufferSizeDefault, setCharset, setCharset, setCharsetDefault, setOpenOptions
checkOrigin, getOrigin, hasOrigin, newByteArrayOrigin, newCharSequenceOrigin, newFileOrigin, newFileOrigin, newInputStreamOrigin, newOutputStreamOrigin, newPathOrigin, newPathOrigin, newReaderOrigin, newURIOrigin, newWriterOrigin, setByteArray, setCharSequence, setFile, setFile, setInputStream, setOrigin, setOutputStream, setPath, setPath, setReader, setURI, setWriter
asThis
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
asSupplier
public Builder()
public FileWriterWithEncoding get() throws IOException
This builder use the aspects File, CharsetEncoder, and append.
You must provide an origin that can be converted to a File by this builder, otherwise, this call will throw an
UnsupportedOperationException
.
UnsupportedOperationException
- if the origin cannot provide a File.IllegalStateException
- if the origin
is null
.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(CharsetEncoder charsetEncoder)
charsetEncoder
- The charsetEncoder to use for encoding.Copyright © 2002–2023 The Apache Software Foundation. All rights reserved.