Package eu.bandm.tools.util.files
Interface TextInput
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
FileInput
,ReaderInput
Realizes access to external text sources.
In nearly all use cases, external texts are either given by a pair
(File × encoding), or as a pair (Reader × sourceInfo).
SourceInfo stands for a human readable document identifier, used
in error messages etc.
These pairs belong together *unavoidably* when processing the text input.
This class gives both situations a unified facade.
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
close()
Close the stream, if there is any.getInfo()
Deliver a human readable text for the source identification.Deliver the stream of decoded characters.static TextInput
Factory method.static TextInput
Factory method.static TextInput
Factory method.
-
Method Details
-
of
Factory method. The encoding is given explicitly. The name of the file will serve as the source information.- Parameters:
file
- to read fromencoding
- the encoding in which to read from the file- Returns:
- an instance which combines the file with the encoding
-
of
Factory method. The source information is given explicitly.- Parameters:
reader
- to read fromreadableSourceInfo
- the info about this source as used in error messages, etc.- Returns:
- an instance which combines the reader with the source info
-
of
Factory method. The source information is missing.- Parameters:
reader
- to read from- Returns:
- an instance which combines the reader with the source info
-
getReader
Reader getReader()Deliver the stream of decoded characters.- Returns:
- the stream of decoded characters.
-
close
Close the stream, if there is any.- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
-
getInfo
Deliver a human readable text for the source identification.- Returns:
- a human readable text for the source identification.
-