1 package org.objectweb.rentacar.util; 2 3 import java.io.File ; 4 import java.io.FileInputStream ; 5 import java.util.Properties ; 6 7 public class PropertiesLoader { 8 9 16 public static String getProperty(String inputFile, String property) throws PropertyLoadingException{ 17 18 Properties prop = new Properties (); 19 try{ 20 if (new File (inputFile).exists()){ 21 prop.load(new FileInputStream (inputFile)); 22 } 23 else { 24 prop.load(PropertiesLoader.class.getClassLoader().getResourceAsStream(inputFile)); 25 } 26 } 27 catch (Exception e){ 28 throw new PropertyLoadingException("Error while loading the file",e); 29 } 30 return (String )prop.get(property); 31 } 32 } 33 | Popular Tags |