Home | History | Annotate | Download | only in internal
      1 package org.testng.internal;
      2 
      3 import java.io.File;
      4 import java.io.FileInputStream;
      5 import java.io.IOException;
      6 import java.util.Properties;
      7 
      8 /**
      9  * This class loads and abstracts remote.properties
     10  *
     11  * @author cbeust
     12  * @author Guy Korland
     13  * @since April 13, 2006
     14  */
     15 public class PropertiesFile {
     16 
     17   private Properties m_properties = new Properties();
     18 
     19   /**
     20    * Loads a Properties file.
     21    *
     22    * @param fileName properties file path
     23    * @throws IOException if an error occurred when reading from the Properties file.
     24    */
     25   public PropertiesFile(String fileName) throws IOException
     26   {
     27 	  FileInputStream fis = null;
     28 	  //
     29 	  // Parse the Properties file
     30 	  //
     31 	  try {
     32 		  fis = new FileInputStream(new File(fileName));
     33 		  m_properties.load(fis);
     34 	  }
     35 	  finally
     36 	  {
     37 		  if( fis != null) {
     38         fis.close();
     39       }
     40 	  }
     41   }
     42 
     43   /**
     44    * Returns the properties loaded.
     45    * @return loaded properties.
     46    */
     47   public Properties getProperties()
     48   {
     49 	  return m_properties;
     50   }
     51 }
     52