Class StreamSubstituter


  • public class StreamSubstituter
    extends Object
    Copies a Reader to a Writer performing string substitution.
    • Constructor Detail

      • StreamSubstituter

        public StreamSubstituter()
    • Method Detail

      • define

        public void define​(String key,
                           String val)
        Define a string to substitute. In the content being filtered, all occurrences of ...
             <subst data="key">otherwise</subst>
         
        will be replaced with the value defined for "key". If the key has not been defined, then "otherwise" will be copied to the output stream. More than one date="key" may be specified in the same <subst> tag in which case they are substituted in order, and "otherwise" is only copied if none of the keys were found.
        Parameters:
        key - file name used as key for cache
        val - string value for representation of the file
      • filter

        public void filter​(File inputFile,
                           PrintWriter o)
                    throws IOException
        Filters data from file.
        Parameters:
        inputFile - that filter will be applied.
        o - output stream filtered content will be written.
        Throws:
        IOException - if content can not be read from
      • getFileContents

        public StringBuffer getFileContents​(File filename)
                                     throws Exception
        Get file content from file to string buffer
        Parameters:
        filename - will be read from
        Returns:
        StringBuffer representation of file content
        Throws:
        Exception - if file can not be read from.