public class BufferedWriterBuilder
extends java.lang.Object
BufferedWriter builderBufferedWriter is created without explicitely stating a Charset it uses, it will use StandardCharsets.UTF_8.
If a BufferedWriter is created without explicitely stating an OpenOption it uses, a new file will be created.
It is mandatory to state a path-parameter.| Constructor and Description |
|---|
BufferedWriterBuilder() |
| Modifier and Type | Method and Description |
|---|---|
java.io.BufferedWriter |
build()
Creates a
BufferedWriter, according to previously set parameters. |
BufferedWriterBuilder |
withCharset(java.nio.charset.Charset charset)
Charset to be used while writing to a file.This parameter is optional. If not stated, a DEFAULT_CHARSET will be used. |
BufferedWriterBuilder |
withCharset(java.lang.String charset)
Charset to be used while writing to a file.This parameter is optional. If not stated, a DEFAULT_CHARSET will be used. |
BufferedWriterBuilder |
withOption(java.nio.file.OpenOption option)
Sets an
OpenOption to be used when opening/creating a file.This parameter can be used multiple times. |
BufferedWriterBuilder |
withPath(java.nio.file.Path path) |
BufferedWriterBuilder |
withPath(java.lang.String path) |
public BufferedWriterBuilder withPath(java.nio.file.Path path)
path - Path of a file that shoud be written intoBufferedWriterBuilder objectpublic BufferedWriterBuilder withPath(java.lang.String path)
path - Path of a file that shoud be written intoBufferedWriterBuilder objectpublic BufferedWriterBuilder withCharset(java.nio.charset.Charset charset)
Charset to be used while writing to a file.DEFAULT_CHARSET will be used.charset - Charset to be used while writing to a fileBufferedWriterBuilder objectpublic BufferedWriterBuilder withCharset(java.lang.String charset)
Charset to be used while writing to a file.DEFAULT_CHARSET will be used.charset - Charset to be used while writing to a fileBufferedWriterBuilder objectpublic BufferedWriterBuilder withOption(java.nio.file.OpenOption option)
OpenOption to be used when opening/creating a file.option - Configuration parameter that states how to open or create a fileBufferedWriterBuilder objectpublic java.io.BufferedWriter build()
throws java.io.IOException
BufferedWriter, according to previously set parameters.BufferedWriterjava.lang.IllegalArgumentException - If parameter path is not properly set.java.io.IOException - If something prevents normal opening/creation of a file.