Class FileReplacer

java.lang.Object
org.jppf.utils.FileReplacer

public class FileReplacer extends Object
Utility to replace multiline content in text files. This is the same kind of utility as the Ant "replace" task, except that it works.
Author:
Laurent Cohen
  • Constructor Details

    • FileReplacer

      public FileReplacer()
  • Method Details

    • replace

      public void replace(NamedArguments args) throws Exception
      Replace, in a set of specified files, a piece of text with another. The text can be multi-lines.
      Parameters:
      args - the parameters for searching, matching replacing.
      Throws:
      Exception - if an error occurs while performing the replacements.
    • main

      public static void main(String... args)
      Main entry point.

      The arguments must be specified as described in the clsss :
      -i searchFile : the file containing the text to search for, can be multi-lines
      -o replacementFile : the file containing the replacement text
      -f rootDir : the root directory from which to search files recursively
      -e extensions : a comma-separated list of file extensions, used as file filter; e.g. java,html,xml
      -p : if specified then the program only shows matching files, but does not do any replacement
      -r : if specified, then the text in the search and replacement files are interpreted as regex and replacement expressions

      Parameters:
      args - defines the text search, the text to replace it with, the file extensions to process, and whether changes are only simulated.