2 *******************************************************************************
\r
3 * Copyright (C) 2008, International Business Machines Corporation and *
\r
4 * others. All Rights Reserved. *
\r
5 *******************************************************************************
\r
7 package com.ibm.icu.impl;
\r
9 import java.io.IOException;
\r
10 import java.io.InputStream;
\r
11 import java.util.MissingResourceException;
\r
12 import java.util.Properties;
\r
15 * ICUConfig is a class used for accessing ICU4J runtime configuration.
\r
17 public class ICUConfig {
\r
18 public static final String CONFIG_PROPS_FILE = "/com/ibm/icu/ICUConfig.properties";
\r
19 private static final Properties CONFIG_PROPS;
\r
22 CONFIG_PROPS = new Properties();
\r
24 InputStream is = ICUData.getStream(CONFIG_PROPS_FILE);
\r
26 CONFIG_PROPS.load(is);
\r
28 } catch (MissingResourceException mre) {
\r
29 // If it does not exist, ignore.
\r
30 } catch (IOException ioe) {
\r
31 // Any IO errors, ignore
\r
36 * Get ICU configuration property value for the given name.
\r
37 * @param name The configuration property name
\r
38 * @return The configuration property value, or null if it does not exist.
\r
40 public static String get(String name) {
\r
41 return get(name, null);
\r
45 * Get ICU configuration property value for the given name.
\r
46 * @param name The configuration property name
\r
47 * @param def The default value
\r
48 * @return The configuration property value. If the property does not
\r
49 * exist, <code>def</code> is returned.
\r
51 public static String get(String name, String def) {
\r
53 // Try the system property first
\r
55 val = System.getProperty(name);
\r
56 } catch (SecurityException e) {
\r
57 // Ignore and fall through
\r
61 val = CONFIG_PROPS.getProperty(name, def);
\r