net.sourceforge.cruisecontrol.util
Class Util

java.lang.Object
  extended bynet.sourceforge.cruisecontrol.util.Util

public final class Util
extends java.lang.Object


Method Summary
static void appendFileToBuffer(java.lang.String fileName, java.lang.StringBuffer out)
          Append the content of the file specified by its path into a StringBuffer
static java.lang.String getOsName()
           
static boolean isWindows()
           
static java.util.Properties loadPropertiesFromFile(java.io.File file)
          Loads a set of properties from the specified properties file.
static org.jdom.Element loadRootElement(java.io.File configFile)
           
static org.jdom.Element loadRootElement(java.io.InputStream in)
           
static java.lang.String readFileToString(java.io.File file)
           
static java.lang.String readFileToString(java.lang.String fileName)
          Return the content of the file specified by its path into a String
static void storePropertiesToFile(java.util.Properties properties, java.lang.String header, java.io.File file)
          Stores the contents of a Properties object to the specifed file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadRootElement

public static org.jdom.Element loadRootElement(java.io.File configFile)
                                        throws CruiseControlException
Throws:
CruiseControlException

loadRootElement

public static org.jdom.Element loadRootElement(java.io.InputStream in)
                                        throws CruiseControlException
Throws:
CruiseControlException

isWindows

public static boolean isWindows()

getOsName

public static java.lang.String getOsName()

loadPropertiesFromFile

public static java.util.Properties loadPropertiesFromFile(java.io.File file)
                                                   throws CruiseControlException,
                                                          java.io.IOException
Loads a set of properties from the specified properties file. The file must exist and be in the proper format. If not, a CruiseControlException is thrown.

Parameters:
file - The File from which to load the properties
Returns:
A Properties object which contains all properties defined in the file.
Throws:
CruiseControlException
java.io.IOException

storePropertiesToFile

public static void storePropertiesToFile(java.util.Properties properties,
                                         java.lang.String header,
                                         java.io.File file)
                                  throws CruiseControlException,
                                         java.io.IOException
Stores the contents of a Properties object to the specifed file. If the file does not exist, it will be created (if possible).

Parameters:
properties - The Properties object which will be stored to file
header - A string which will be written to the first line of the properties file as a comment. Can be null.
file - The properties file to which the properties will be written.
Throws:
CruiseControlException
java.io.IOException

readFileToString

public static java.lang.String readFileToString(java.lang.String fileName)
                                         throws java.io.IOException
Return the content of the file specified by its path into a String

Throws:
java.io.IOException

readFileToString

public static java.lang.String readFileToString(java.io.File file)
                                         throws java.io.IOException
Throws:
java.io.IOException

appendFileToBuffer

public static void appendFileToBuffer(java.lang.String fileName,
                                      java.lang.StringBuffer out)
                               throws java.io.IOException
Append the content of the file specified by its path into a StringBuffer

Throws:
java.io.IOException