copyright The Portico Project 2008.

org.portico.shared
Class FileUtilities

java.lang.Object
  extended by org.portico.shared.FileUtilities

public class FileUtilities
extends Object


Constructor Summary
FileUtilities()
           
 
Method Summary
static File getRidFile()
          This method firstly checks the environment variable RTI_RID_FILE for the location of the RID file.
static boolean isXMLFile(String theFile)
          Returns whether this file is an XML file.
static void loadPropertiesFile(String theFile)
          Loads the specified properties file and sets all properties contained within as System properties, overriding any values for previously set keys.
private static InputStream openFile(String theFile)
          Attempts to open the specified file using a two stage process: 1. checks the file system for the file 2. uses the resource locator to check the classpath/jar files for the file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtilities

public FileUtilities()
Method Detail

openFile

private static InputStream openFile(String theFile)
                             throws FileNotFoundException,
                                    IOException
Attempts to open the specified file using a two stage process: 1. checks the file system for the file 2. uses the resource locator to check the classpath/jar files for the file

Throws:
FileNotFoundException
IOException

isXMLFile

public static boolean isXMLFile(String theFile)
                         throws FileNotFoundException,
                                IOException
Returns whether this file is an XML file. The method checks the first non blank line of the file for an XML tag.

Parameters:
theFile - An object of type File representing the file to perform the check on
Returns:
A boolean, true if the file appears to be an XML file, false if it is not
Throws:
FileNotFoundException
IOException

loadPropertiesFile

public static void loadPropertiesFile(String theFile)
                               throws FileNotFoundException,
                                      IOException
Loads the specified properties file and sets all properties contained within as System properties, overriding any values for previously set keys. Please note that due to limitations with the Properties.load() method, specifying a properties file that is not well formed will fail silently without throwing an exception.

Parameters:
propertiesFile - An object of type file representing the properties file to load
Throws:
FileNotFoundException
IOException

getRidFile

public static File getRidFile()
This method firstly checks the environment variable RTI_RID_FILE for the location of the RID file. If the variable RTI_RID_FILE is defined and the file contained within exists and can be read, then that file is returned. If not, the file specified in PorticoConstants.DEFAULT_RTI_RID is checked. If the file exists and can be read then that file is returned. If both paths lead to nothing, then null is returned.

Returns:
An object of type File representing the RID file. If the RID file cannot be found at RTI_RID_FILE or PorticoConstants.DEFAULT_RTI_RID then null is returned

copyright The Portico Project 2008.