Initializes the settings all Settings objects will use. This should be called before any setting requests. Subsequent calls replace all old settings and then Settings contains only the new settings. The file #DEF_SETTINGS_FILE, if exists, is always read. @param propFile Path to the property
(String propFile)
| 248 | * @throws SettingsError If loading the settings file(s) didn't succeed |
| 249 | */ |
| 250 | public static void init(String propFile) throws SettingsError { |
| 251 | String outFile; |
| 252 | try { |
| 253 | if (new File(DEF_SETTINGS_FILE).exists()) { |
| 254 | Properties defProperties = new Properties(); |
| 255 | defProperties.load(new FileInputStream(DEF_SETTINGS_FILE)); |
| 256 | props = new Properties(defProperties); |
| 257 | } |
| 258 | else { |
| 259 | props = new Properties(); |
| 260 | } |
| 261 | if (propFile != null) { |
| 262 | props.load(new FileInputStream(propFile)); |
| 263 | } |
| 264 | } catch (IOException e) { |
| 265 | throw new SettingsError(e); |
| 266 | } |
| 267 | |
| 268 | outFile = props.getProperty(SETTING_OUTPUT_S); |
| 269 | if (outFile != null) { |
| 270 | if (outFile.trim().length() == 0) { |
| 271 | out = System.out; |
| 272 | } else { |
| 273 | try { |
| 274 | out = new PrintStream(new File(outFile)); |
| 275 | } catch (FileNotFoundException e) { |
| 276 | throw new SettingsError("Can't open Settings output file:" + |
| 277 | e); |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | /** |
| 284 | * Reads another settings file and adds the key-value pairs to the current |