org.jppf.utils
Class FileReplacer

java.lang.Object
  extended by 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

Nested Class Summary
static class FileReplacer.ReplacerFilter
          File filter based on a set of extensions.
 
Constructor Summary
FileReplacer()
           
 
Method Summary
static void main(String... args)
          Main entry point.
 void replace(String rootDir, String srcFile, String destFile, String ext, boolean searchOnly)
          Replace, in a set of specified files, a string with another.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileReplacer

public FileReplacer()
Method Detail

replace

public void replace(String rootDir,
                    String srcFile,
                    String destFile,
                    String ext,
                    boolean searchOnly)
             throws Exception
Replace, in a set of specified files, a string with another.

Parameters:
rootDir - the root directory from where to start search.
srcFile - file containing the content to replace.
destFile - file containing the replacement content.
ext - comma-separated list of file extensions to process.
searchOnly - determines whether only the search is performed (no replacement).
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 follows:
args[0] : the file containing the text to search for
args[1] : the file containing the replacement text
args[2] : a list of comma-separated file extensions, without dots and no spaces allowed (e.g. "java,xml")
args[3] : true to indicate that the replacements should only be simulated (i.e changes preview), false to really peform the replacements.

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


Copyright © 2005-2010 JPPF Team.