public class NamedReader extends NamedCloseable
Constructor and Description |
---|
NamedReader(java.lang.String name,
java.io.Reader reader)
Create a new instance with the given name associated to the given reader.
|
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.Reader |
getReader()
Returns the underlying Reader (will never be null).
|
static NamedReader |
open(java.io.File file,
java.nio.charset.Charset charset)
Opens the provided file and returns the reader along with the file name.
|
static NamedReader |
open(java.lang.String filename,
java.nio.charset.Charset charset)
Opens the file specified by the given filename and returns the reader along with the file name.
|
close, getName, setName
public NamedReader(java.lang.String name, java.io.Reader reader)
name
- The name of the reader (must not be null).reader
- The reader to be associated with the name (must not be null).java.lang.IllegalArgumentException
- If either name or reader is null.public static NamedReader 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 found.public static NamedReader 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 found.public java.io.Reader getReader()
protected java.io.Closeable getCloseable()
NamedCloseable
getCloseable
in class NamedCloseable