1 4 package uk.ac.roe.antigen.utils; 5 6 import java.io.IOException ; 7 import java.util.Properties ; 8 import java.util.logging.Logger ; 9 10 14 public class Config { 15 18 private static final Logger logger = Logger.getLogger(Config.class.getName()); 19 20 21 private static Properties props = new Properties (); 22 public static void load(String path) { 23 logger.fine("Loading properties off classpath from "+path); 24 try { 25 props.load(Config.class.getResourceAsStream(path)); 26 } catch (Exception e) { 27 logger.severe("Unable to load configuration file ...aborting."); 28 throw new RuntimeException ("Unable to load properties",e); 29 } 30 } 31 36 public static String getProperty(String name) { 37 String property = props.getProperty(name); 38 if (property=="") property=null; 39 return property; 40 } 41 47 public static String getProperty(String name, String defolt) { 48 String value = getProperty(name); 49 return value !=null ? value : defolt; 50 } 51 56 public static void setProperty(String key, String value) { 57 props.setProperty(key, value); 58 } 59 60 } 61 | Popular Tags |