public class NamedWriter extends NamedCloseable
Constructor and Description |
---|
NamedWriter(java.lang.String name,
java.io.Writer writer)
Create a new instance with the given name associated to the given writer.
|
Modifier and Type | Method and Description |
---|---|
protected java.io.Closeable |
getCloseable()
Returns the closeable that is associated with the name defined in this class.
|
java.io.Writer |
getWriter()
Returns the underlying Writer (will never be null).
|
static NamedWriter |
open(java.io.File file,
java.nio.charset.Charset charset)
Opens the provided file and returns the writer along with the file name.
|
static NamedWriter |
open(java.lang.String filename,
java.nio.charset.Charset charset)
Opens the file specified by the given filename and returns the writer along with the file name.
|
close, getName, setName
public NamedWriter(java.lang.String name, java.io.Writer writer)
name
- The name of the writer (must not be null).writer
- The writer to be associated with the name (must not be null).java.lang.IllegalArgumentException
- If either name or writer is null.public static NamedWriter open(java.io.File file, java.nio.charset.Charset charset) throws java.io.FileNotFoundException
file
- The file to be opened (must not be null).charset
- The character encoding of the file.java.io.FileNotFoundException
- If the provided file cannot be opened/created.public static NamedWriter open(java.lang.String filename, java.nio.charset.Charset charset) throws java.io.FileNotFoundException
filename
- The file to be opened (must not be null).charset
- The character encoding of the file.java.io.FileNotFoundException
- If a file with the given name cannot be opened/created.public java.io.Writer getWriter()
protected java.io.Closeable getCloseable()
NamedCloseable
getCloseable
in class NamedCloseable