public static class WriterOutputStream.Builder extends org.apache.commons.io.build.AbstractStreamBuilder<WriterOutputStream,WriterOutputStream.Builder>
WriterOutputStream
instance.
For example:
WriterOutputStream s = WriterOutputStream.builder()
.setPath(path)
.setBufferSize(8192)
.setCharset(StandardCharsets.UTF_8)
.setWriteImmediately(false)
.get();
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
WriterOutputStream |
get()
Constructs a new instance.
|
WriterOutputStream.Builder |
setCharset(java.nio.charset.Charset charset) |
WriterOutputStream.Builder |
setCharset(java.lang.String 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. |
getCharset, setBufferSize, setBufferSize, setOpenOptions
setByteArray, setCharSequence, setFile, setFile, setInputStream, setOutputStream, setPath, setPath, setReader, setURI, setWriter
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
asSupplier
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)
setCharset
in class org.apache.commons.io.build.AbstractStreamBuilder<WriterOutputStream,WriterOutputStream.Builder>
public WriterOutputStream.Builder setCharset(java.lang.String charset)
setCharset
in class org.apache.commons.io.build.AbstractStreamBuilder<WriterOutputStream,WriterOutputStream.Builder>
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.Copyright © 2010 - 2023 Adobe. All Rights Reserved