public class EditableFile
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
java.lang.String |
comment |
| Constructor and Description |
|---|
EditableFile(java.lang.String filestr) |
| Modifier and Type | Method and Description |
|---|---|
void |
append(java.lang.String text)
Appends the specified text to the file.
|
java.lang.String |
backup()
Write pending changes to a backup file (the original file name with a timestamp appended).
|
void |
commentOutAllLinesMatching(java.lang.String regex)
Comments out all lines matching the specified regex.
|
void |
commentOutFirstLineMatching(java.lang.String regex)
Comments out first line matching the specified regex.
|
boolean |
contains(java.lang.String regex)
Returns true if the file contains the specified regex, false otherwise.
|
java.lang.String |
getContents()
Returns the file contents in string format.
|
java.lang.String |
getLocation()
Returns the path to the file we are editing.
|
java.lang.String |
insertAfterLocator(java.lang.String regex,
java.lang.String textToInsert,
boolean isMultiLine)
Modifies the file to insert the specified text on the line after the *first* instance of the locator statement.
|
java.lang.String |
insertBeforeLocator(java.lang.String regex,
java.lang.String textToInsert,
boolean isMultiLine)
Modifies the file to insert the specified text on the line before the *first* instance of the locator statement.
|
java.lang.String |
replaceAll(java.lang.String regex,
java.lang.String replacement)
Modifies the file to replace all occurrences of the specified regex with the specified replacement string.
|
java.lang.String |
replaceAll(java.lang.String regex,
java.lang.String replacement,
boolean isMultiLine)
Modifies the file to replace all occurrences of the specified regex with the specified replacement string.
|
java.lang.String |
replaceFirst(java.lang.String regex,
java.lang.String replacement)
Modifies the file to replace the first occurrence of the specified regex with the specified replacement string.
|
java.lang.String |
replaceFirst(java.lang.String regex,
java.lang.String replacement,
boolean isMultiLine)
Modifies the file to replace the first occurrence of the specified regex with the specified replacement string.
|
public EditableFile(java.lang.String filestr)
throws java.lang.NullPointerException,
java.io.FileNotFoundException,
java.io.IOException
java.lang.NullPointerExceptionjava.io.FileNotFoundExceptionjava.io.IOExceptionpublic java.lang.String getContents()
public java.lang.String getLocation()
public boolean contains(java.lang.String regex)
public java.lang.String replaceFirst(java.lang.String regex,
java.lang.String replacement)
public java.lang.String replaceFirst(java.lang.String regex,
java.lang.String replacement,
boolean isMultiLine)
public java.lang.String replaceAll(java.lang.String regex,
java.lang.String replacement)
replaceFirst(String, String).public java.lang.String replaceAll(java.lang.String regex,
java.lang.String replacement,
boolean isMultiLine)
replaceFirst(String, String, boolean).public java.lang.String insertBeforeLocator(java.lang.String regex,
java.lang.String textToInsert,
boolean isMultiLine)
public java.lang.String insertAfterLocator(java.lang.String regex,
java.lang.String textToInsert,
boolean isMultiLine)
public void commentOutFirstLineMatching(java.lang.String regex)
public void commentOutAllLinesMatching(java.lang.String regex)
public void append(java.lang.String text)
public java.lang.String backup()