public class ReplaceStringInFiles extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ReplaceStringInFiles.ReplacementResult
Result class for string replacement.
|
Constructor and Description |
---|
ReplaceStringInFiles() |
Modifier and Type | Method and Description |
---|---|
static int |
indexOfCaseSensitive(String mainStr,
String argStr,
int start,
boolean caseSensitive) |
static void |
main(String[] args)
Replace a certain string with other strings in files.
|
static void |
replaceStringInFiles(File dir,
FileFilter fileFilter,
String toReplace,
String replacement,
boolean caseSensitive)
Replace a string in all files of a directory, recursively.
|
static void |
replaceStringInString(String text,
String toReplace,
String replacement,
ReplaceStringInFiles.ReplacementResult res,
boolean caseSensitive)
Replace occurrences of
toReplace in text by
replacement. |
public static int indexOfCaseSensitive(String mainStr, String argStr, int start, boolean caseSensitive)
mainStr
- The given string object.argStr
- The given string argument.start
- -caseSensitive
- --1
is returned.public static final void replaceStringInString(String text, String toReplace, String replacement, ReplaceStringInFiles.ReplacementResult res, boolean caseSensitive)
toReplace
in text
by
replacement.
text
- The text where the replacement should happen.toReplace
- The string that should be replaced.replacement
- The string it should be replaced with.res
- The result object, containing the result string and the number of times replacement
happened.caseSensitive
- -public static final void replaceStringInFiles(File dir, FileFilter fileFilter, String toReplace, String replacement, boolean caseSensitive) throws IOException
dir
- The directory where replacement should happen.fileFilter
- A file filter for which files replacement should happen.toReplace
- String which should be replaced.replacement
- String it should be replaced with.caseSensitive
- -IOException
- Whenever anything goes wrong reading or writing a file.public static void main(String[] args)
java org.apache.uima.util.ReplaceStringInFile /home/tom/stuff .prop $ROOT$ /home/tom/root
args
- dir, extension toreplace replacement [-ignorecase]Copyright © 2006–2021 The Apache Software Foundation. All rights reserved.