public class PropUtil { private static Map<String, String> cache = null; private static final String[] PROP_FILES = new String[] { "resources/app", "resources/message", "resources/jdbc" }; private static final String[] TRUE_LITERATURES = new String[] { "1", "YES", "TRUE" }; public static boolean getBoolProperty(final String key) { String val = getProperty(key).toUpperCase(); for (String t : TRUE_LITERATURES) { if (t.equals(val)) { return true; } } return false; }; public static int getIntProperty(final String key) { return Integer.parseInt(getProperty(key)); } public static String getProperty(final String key) { if (cache == null) { cache = readPropFiles(); } return cache.get(key); } private static synchronized Map<String, String> readPropFiles() { Map<String, String> retMap = new HashMap<String, String>(); for (String propFile : PROP_FILES) { PropertyResourceBundle prop = (PropertyResourceBundle) ResourceBundle.getBundle(propFile); for (Enumeration<String> keyEnum = prop.getKeys(); keyEnum.hasMoreElements();) { String propKey = keyEnum.nextElement(); retMap.put(propKey, prop.getString(propKey)); } } return retMap; } private PropUtil() { } }