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();
| Constructor and Description |
|---|
Builder() |
| Modifier and Type | Method and Description |
|---|---|
WriterOutputStream |
get()
Constructs a new instance.
|
WriterOutputStream.Builder |
setCharset(Charset charset)
Sets the Charset.
|
WriterOutputStream.Builder |
setCharset(String charset)
Sets the Charset.
|
WriterOutputStream.Builder |
setCharsetDecoder(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, setBufferSizeDefault, 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, waitasSupplierpublic Builder()
public WriterOutputStream get() throws 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.
UnsupportedOperationException - if the origin cannot provide a Writer.IOException - if an I/O error occurs.AbstractStreamBuilder.getWriter()public WriterOutputStream.Builder setCharset(Charset charset)
AbstractStreamBuilderSubclasses may ignore this setting.
setCharset in class AbstractStreamBuilder<WriterOutputStream,WriterOutputStream.Builder>charset - the Charset, null resets to the default.public WriterOutputStream.Builder setCharset(String charset)
AbstractStreamBuilderSubclasses may ignore this setting.
setCharset in class AbstractStreamBuilder<WriterOutputStream,WriterOutputStream.Builder>charset - the Charset name, null resets to the default.public WriterOutputStream.Builder setCharsetDecoder(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 © 2002–2023 The Apache Software Foundation. All rights reserved.