public static class WriterOutputStream.Builder extends AbstractStreamBuilder<WriterOutputStream,WriterOutputStream.Builder>
WriterOutputStream
instance.
For example:
WriterOutputStream s = WriterOutputStream.builder()
.setPath(path)
.setBufferSize(8192)
.setCharset(StandardCharsets.UTF_8)
.setWriteImmediately(false)
.get();
Modifier and Type | Field and Description |
---|---|
private java.nio.charset.CharsetDecoder |
charsetDecoder |
private boolean |
writeImmediately |
Constructor and Description |
---|
Builder()
Constructs a new Builder.
|
Modifier and Type | Method and Description |
---|---|
WriterOutputStream |
get()
Constructs a new instance.
|
WriterOutputStream.Builder |
setCharset(java.nio.charset.Charset charset)
Sets the Charset.
|
WriterOutputStream.Builder |
setCharset(java.lang.String charset)
Sets the Charset.
|
WriterOutputStream.Builder |
setCharsetDecoder(java.nio.charset.CharsetDecoder charsetDecoder)
Sets the charset decoder.
|
WriterOutputStream.Builder |
setWriteImmediately(boolean writeImmediately)
Sets whether the output buffer will be flushed after each write operation (
true ), i.e. |
getBufferSize, getBufferSizeDefault, getCharSequence, getCharset, getCharsetDefault, getInputStream, getOpenOptions, getOutputStream, getPath, getWriter, setBufferSize, setBufferSize, setBufferSizeChecker, setBufferSizeDefault, setBufferSizeMax, 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
private java.nio.charset.CharsetDecoder charsetDecoder
private boolean writeImmediately
public WriterOutputStream get() throws java.io.IOException
This builder use the aspect Writer, OpenOption[], Charset, CharsetDecoder, buffer size and writeImmediately.
You must provide an origin that can be converted to a Writer by this builder, otherwise, this call will throw an
UnsupportedOperationException
.
java.lang.UnsupportedOperationException
- if the origin cannot provide a Writer.java.io.IOException
- if an I/O error occurs.AbstractStreamBuilder.getWriter()
public WriterOutputStream.Builder setCharset(java.nio.charset.Charset charset)
AbstractStreamBuilder
Subclasses may ignore this setting.
setCharset
in class AbstractStreamBuilder<WriterOutputStream,WriterOutputStream.Builder>
charset
- the Charset, null resets to the default.public WriterOutputStream.Builder setCharset(java.lang.String charset)
AbstractStreamBuilder
Subclasses may ignore this setting.
setCharset
in class AbstractStreamBuilder<WriterOutputStream,WriterOutputStream.Builder>
charset
- the Charset name, null resets to the default.public WriterOutputStream.Builder setCharsetDecoder(java.nio.charset.CharsetDecoder charsetDecoder)
charsetDecoder
- the charset decoder.public WriterOutputStream.Builder setWriteImmediately(boolean writeImmediately)
true
), i.e. all available data will be written to the underlying
Writer
immediately. If false
, the output buffer will only be flushed when it overflows or when WriterOutputStream.flush()
or WriterOutputStream.close()
is called.writeImmediately
- If true
the output buffer will be flushed after each write operation, i.e. all available data will be written to the
underlying Writer
immediately. If false
, the output buffer will only be flushed when it overflows or when
WriterOutputStream.flush()
or WriterOutputStream.close()
is called.