| java.lang.Object de.schlund.pfixxml.util.FileUtils
FileUtils | public class FileUtils (Code) | | This class contains a set of commonly used utility methods for the files.
author: mleidig@schlund.de |
Method Summary | |
public static void | copyFile(File srcFile, File destFile) Copies a source file to a target file. | public static void | copyFiles(File srcDir, File destDir, String... regexps) Copies files from source to destination dir. | public static String | load(File file, String encoding) Read a text file into a string. | public static void | save(String fileContent, File file, String encoding) Saves a string to a text file. | public static void | searchAndReplace(File file, String encoding, String regexp, String replacement) Reads a text file into a string and replaces each substring that matches the regular
expression by a given replacement. |
copyFile | public static void copyFile(File srcFile, File destFile) throws IOException(Code) | | Copies a source file to a target file.
Parameters: srcFile - source file Parameters: destFile - target file throws: IOException - |
copyFiles | public static void copyFiles(File srcDir, File destDir, String... regexps) throws IOException(Code) | | Copies files from source to destination dir. The files can be filtered by name using one
or more regular expressions (e.g. ".*gif", ".*jpg").
Parameters: srcDir - source directory Parameters: destDir - destination directory Parameters: regexps - regular expressions for file names throws: IOException - |
load | public static String load(File file, String encoding) throws IOException(Code) | | Read a text file into a string.
Parameters: file - - the text file Parameters: encoding - - text file content's encoding the file content as string throws: IOException - |
save | public static void save(String fileContent, File file, String encoding) throws IOException(Code) | | Saves a string to a text file.
Parameters: fileContent - - the file content string Parameters: file - - the target file Parameters: encoding - - the text encoding throws: IOException - |
searchAndReplace | public static void searchAndReplace(File file, String encoding, String regexp, String replacement)(Code) | | Reads a text file into a string and replaces each substring that matches the regular
expression by a given replacement. Then the changed string is stored back to the file.
Parameters: file - - the text file Parameters: encoding - - the file content's encoding Parameters: regexp - - the regular expression to match substrings Parameters: replacement - - the replacement for matched substrings |
|
|