1 54 55 package junitx.util; 56 57 import java.io.FileInputStream ; 58 import java.util.Properties ; 59 60 82 public class PropertyManager { 83 84 private static Properties props; 85 86 static { 87 try { 88 props = new Properties (); 89 props.load(new FileInputStream (System.getProperty("PropertyManager.file"))); 90 } catch (Exception e) { 91 e.printStackTrace(System.err); 92 } 93 } 94 95 98 private PropertyManager() { 99 } 100 101 109 public static Object setProperty(String key, 110 String value) 111 throws NullPointerException { 112 return props.setProperty(key, value); 113 } 114 115 123 public static String getProperty(String key) { 124 return getProperty(key, null); 125 } 126 127 136 public static String getProperty(String key, 137 String defaultValue) { 138 if (props == null) { 139 return null; 140 } 141 return props.getProperty(key, defaultValue); 142 } 143 144 } 145 | Popular Tags |