| java.lang.Object com.sun.portal.fabric.util.FileUtil
FileUtil | public class FileUtil (Code) | | |
Method Summary | |
public static boolean | appendLineInFile(File file, String pattern, String text) | public static boolean | appendLineInFile(File file, String pattern, String text, int mode) | public static boolean | appendToFile(File file, String text, boolean checkIfExists) | public static void | changeFilePermissions(String file, String permissions) Changes the permissions of the given file to the given
permissions. | public static void | changeFilePermissions(File file, String permissions) Changes the permissions of the given file to the given
permissions. | public static boolean | copyDir(String fromDirName, String toDirName) | public static boolean | copyDir(String fromDirName, String toDirName, boolean resolveLinks) | public static boolean | copyFile(String fromFilename, String toFilename) | public static boolean | copyFile(File fromFile, File toFile) | public static boolean | copyFile(File fromFile, File toFile, boolean deleteSourceFile) | public static String | createPasswordFile(String data) | public static void | debug(String str) | public static String | decoratePath(String path) | public static boolean | deleteDir(String dirName) | public static boolean | deleteDir(File dir) | public static boolean | deleteLineInFile(File file, String pattern) | public static boolean | deleteLineInFile(File file, String pattern, int mode) | public static boolean | deleteSectionInFile(File file, String start, String end) Delete section from start token to end token in file.
If start token is not found, so not delete anything.
If start token is found, delete every line till end token is found.
If end token is not found, do not delete anything.
If token is found in line, the entire line is deleted
Assume that start and end tokens are in different lines, and end token
always appears after start token.
Assume that the section appears only once in the file
Parameters: file - Parameters: start - - Start token of section. Parameters: end - - End token of section true if section found and deleted. | public static boolean | directoryExists(String dirName) | public static File | extractFileFromJar(String jarPath, String filePath) | public static File | extractFileFromJar(String jarPath, String filePath, boolean keepFileAfterExist) | public static void | extractJar(String jarPath, String targetPath) | public static String | extractPatternTillEOL(File file, String key, String separator) | public static boolean | fileExists(String fileName) | public static String | findPatternInFile(File file, String pattern) | public static String | findTextInFile(File file, String text) | public static String | getAttributeValue(File sXMLFile, String xpath, String attr) Read an xml file into an xml document (org.jdom.Document) and return
the request attribute value, given an xpath. | public static FilenameFilter | getExtensionFilter(String ext) | public static boolean | getFiles(File dir, List files) | public static boolean | getFiles(File dir, List files, String ext) | public static String | getQuotedKeyValueInText(String key, String text) | public static String | getRandomDirName() | public static String | getRandomString() | public static BufferedReader | getUTF8BufferedReader(File fileName) Gets Buffered Reader initialized with UTF-8 encoding
Parameters: File - Object from which data needs to be read. | public static BufferedWriter | getUTF8BufferedWriter(File fileName) Gets Buffered Writer intialized UTF-8 encoding
Parameters: File - Object to which data needs to be read. | public static boolean | makeDir(String dirName) | public static boolean | replaceLineInFile(File file, String pattern, String text) | public static String | replaceToken(String str, String token, String value) | public static boolean | replaceTokenInFile(File origFile, File newFile, String token, String value) | public static boolean | replaceTokenInFile(File file, String token, String value) | public static boolean | replaceTokensInFile(File file, String[] tokens, String[] values) |
APPEND_ALL_OCCURANCES | final public static int APPEND_ALL_OCCURANCES(Code) | | |
APPEND_ALL_OCCURANCES_STARTING_WITH | final public static int APPEND_ALL_OCCURANCES_STARTING_WITH(Code) | | |
APPEND_FIRST_OCCURANCE | final public static int APPEND_FIRST_OCCURANCE(Code) | | |
APPEND_FIRST_OCCURANCE_STARTING_WITH | final public static int APPEND_FIRST_OCCURANCE_STARTING_WITH(Code) | | |
DELETE_ALL_OCCURANCES | final public static int DELETE_ALL_OCCURANCES(Code) | | |
DELETE_ALL_OCCURANCES_STARTING_WITH | final public static int DELETE_ALL_OCCURANCES_STARTING_WITH(Code) | | |
DELETE_FIRST_OCCURANCE | final public static int DELETE_FIRST_OCCURANCE(Code) | | |
DELETE_FIRST_OCCURANCE_STARTING_WITH | final public static int DELETE_FIRST_OCCURANCE_STARTING_WITH(Code) | | |
REPLACED_ALL_OCCURANCES_STARTING_WITH | final public static int REPLACED_ALL_OCCURANCES_STARTING_WITH(Code) | | |
REPLACE_ALL_OCCURANCES | final public static int REPLACE_ALL_OCCURANCES(Code) | | |
REPLACE_FIRST_OCCURANCE | final public static int REPLACE_FIRST_OCCURANCE(Code) | | |
REPLACE_FIRST_OCCURANCE_STARTING_WITH | final public static int REPLACE_FIRST_OCCURANCE_STARTING_WITH(Code) | | |
appendLineInFile | public static boolean appendLineInFile(File file, String pattern, String text, int mode)(Code) | | |
appendToFile | public static boolean appendToFile(File file, String text, boolean checkIfExists)(Code) | | |
changeFilePermissions | public static void changeFilePermissions(String file, String permissions)(Code) | | Changes the permissions of the given file to the given
permissions. On UNIX systems, permissions can either be in
string (symbolic) mode or octal numbers. However, on Microsoft
Windows systems, permissions must be in octal numbers. In
addition, group and other permissions must not be set
(i.e. permssions must be in the form "x00").
Parameters: file - the file where its permssions are to be changed. Parameters: permissions - the permssions of the file to be changed to. |
changeFilePermissions | public static void changeFilePermissions(File file, String permissions)(Code) | | Changes the permissions of the given file to the given
permissions. On UNIX systems, permissions can either be in
string (symbolic) mode or octal numbers. However, on Microsoft
Windows systems, permissions must be in octal numbers. In
addition, group and other permissions must not be set
(i.e. permssions must be in the form "x00").
Parameters: file - the file where its permssions are to be changed. Parameters: permissions - the permssions of the file to be changed to. |
copyDir | public static boolean copyDir(String fromDirName, String toDirName, boolean resolveLinks)(Code) | | |
copyFile | public static boolean copyFile(File fromFile, File toFile)(Code) | | |
copyFile | public static boolean copyFile(File fromFile, File toFile, boolean deleteSourceFile)(Code) | | |
createPasswordFile | public static String createPasswordFile(String data)(Code) | | Creates a file of random name after writing the data
|
debug | public static void debug(String str)(Code) | | Public methods
|
deleteDir | public static boolean deleteDir(String dirName)(Code) | | |
deleteDir | public static boolean deleteDir(File dir)(Code) | | |
deleteLineInFile | public static boolean deleteLineInFile(File file, String pattern)(Code) | | |
deleteLineInFile | public static boolean deleteLineInFile(File file, String pattern, int mode)(Code) | | |
deleteSectionInFile | public static boolean deleteSectionInFile(File file, String start, String end)(Code) | | Delete section from start token to end token in file.
If start token is not found, so not delete anything.
If start token is found, delete every line till end token is found.
If end token is not found, do not delete anything.
If token is found in line, the entire line is deleted
Assume that start and end tokens are in different lines, and end token
always appears after start token.
Assume that the section appears only once in the file
Parameters: file - Parameters: start - - Start token of section. Parameters: end - - End token of section true if section found and deleted. false otherwise. |
directoryExists | public static boolean directoryExists(String dirName)(Code) | | |
fileExists | public static boolean fileExists(String fileName)(Code) | | |
findPatternInFile | public static String findPatternInFile(File file, String pattern)(Code) | | Returns first line in file that matches pattern
If pattern not found returns null
Parameters: file - Parameters: pattern - - regex defining pattern to be matched |
getAttributeValue | public static String getAttributeValue(File sXMLFile, String xpath, String attr)(Code) | | Read an xml file into an xml document (org.jdom.Document) and return
the request attribute value, given an xpath.
|
getQuotedKeyValueInText | public static String getQuotedKeyValueInText(String key, String text)(Code) | | Searches for key with quoted value in text and returns value
Parameters: key - Parameters: text - value without quotes |
getRandomDirName | public static String getRandomDirName()(Code) | | a random number string which is 8 digits or less in length |
getRandomString | public static String getRandomString()(Code) | | a random number string which is 8 digits or less in length |
getUTF8BufferedReader | public static BufferedReader getUTF8BufferedReader(File fileName)(Code) | | Gets Buffered Reader initialized with UTF-8 encoding
Parameters: File - Object from which data needs to be read. BufferedReader Object initialized with UTF-8 encoding |
getUTF8BufferedWriter | public static BufferedWriter getUTF8BufferedWriter(File fileName)(Code) | | Gets Buffered Writer intialized UTF-8 encoding
Parameters: File - Object to which data needs to be read. BufferedWriter Object initialized with UTF-8 encoding |
replaceTokensInFile | public static boolean replaceTokensInFile(File file, String[] tokens, String[] values)(Code) | | |
|
|