org.gridbus.broker.util
Class FileOpsUtil

java.lang.Object
  extended by org.gridbus.broker.util.FileOpsUtil

public class FileOpsUtil
extends java.lang.Object

This class has utility methods for operations such as finding and replacing specific strings / lines in a file.

Version:
1.0
Author:
Srikumar Venugopal (srikumar@cs.mu.oz.au)

Constructor Summary
FileOpsUtil()
           
 
Method Summary
static void copyFile(java.lang.String source, java.lang.String destination, boolean overwrite)
           
static java.lang.String findParaminFile(java.lang.String filename, java.lang.String param)
          Returns the complete line which contains the string 'param' in the file 'filename', or null if the param is not found in the file
static void replaceParaminFile(java.lang.String oldfile, java.lang.String oldline, java.lang.String newfile, java.lang.String newline)
          Replaces the complete line 'oldline' in the 'oldfile' with the 'newline' in the 'newfile' or null if the param is not found in the file
static java.lang.String replaceString(java.lang.String str, java.lang.String pattern, java.lang.String replace)
          Replaces the string pattern in an input string with another string
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileOpsUtil

public FileOpsUtil()
Method Detail

findParaminFile

public static java.lang.String findParaminFile(java.lang.String filename,
                                               java.lang.String param)
                                        throws java.io.FileNotFoundException,
                                               java.io.IOException
Returns the complete line which contains the string 'param' in the file 'filename', or null if the param is not found in the file

Parameters:
filename -
param -
Returns:
string - line containing the param value in the file or null if the param is not found
Throws:
java.io.FileNotFoundException
java.io.IOException

replaceParaminFile

public static void replaceParaminFile(java.lang.String oldfile,
                                      java.lang.String oldline,
                                      java.lang.String newfile,
                                      java.lang.String newline)
                               throws java.io.FileNotFoundException,
                                      java.io.IOException
Replaces the complete line 'oldline' in the 'oldfile' with the 'newline' in the 'newfile' or null if the param is not found in the file

Parameters:
oldfile - : file to search
oldline - : line to search for
newfile - : new file to be written out
newline - : new line which will replace the old line
Throws:
java.io.FileNotFoundException
java.io.IOException

replaceString

public static java.lang.String replaceString(java.lang.String str,
                                             java.lang.String pattern,
                                             java.lang.String replace)
Replaces the string pattern in an input string with another string

Parameters:
str - : string to search
pattern - : pattern to search for
replace - : string which will replace the pattern
Returns:
new string which has the pattern replaced

copyFile

public static void copyFile(java.lang.String source,
                            java.lang.String destination,
                            boolean overwrite)
Parameters:
source -
destination -
overwrite -