List of usage examples for java.util PropertyResourceBundle getObject
public final Object getObject(String key)
From source file:org.eclipse.birt.report.utility.ParameterAccessor.java
/** * Returns the application properties/* w w w .j a v a2s . co m*/ * * @param context * @param props * @return */ public synchronized static Map initViewerProps(ServletContext context, Map props) { // initialize map if (props == null) props = new HashMap(); // get config file String file = context.getInitParameter(INIT_PARAM_CONFIG_FILE); if (file == null || file.trim().length() <= 0) file = IBirtConstants.DEFAULT_VIEWER_CONFIG_FILE; try { InputStream is = null; if (isRelativePath(file)) { // realtive path if (!file.startsWith("/")) //$NON-NLS-1$ file = "/" + file; //$NON-NLS-1$ is = context.getResourceAsStream(file); } else { // absolute path is = new FileInputStream(file); } // parse the properties file PropertyResourceBundle bundle = new PropertyResourceBundle(is); if (bundle != null) { Enumeration<String> keys = bundle.getKeys(); while (keys != null && keys.hasMoreElements()) { String key = keys.nextElement(); String value = (String) bundle.getObject(key); if (key != null && value != null) props.put(key, value); } } } catch (Exception e) { } return props; }
From source file:org.pentaho.platform.plugin.services.importer.LocaleFilesProcessor.java
public Properties loadProperties(InputStream inputStream) throws IOException { assert inputStream != null; final Properties properties = new Properties(); final PropertyResourceBundle rb = new PropertyResourceBundle(inputStream); final Enumeration<?> keyEnum = rb.getKeys(); while (keyEnum.hasMoreElements()) { final Object key = keyEnum.nextElement(); assert key != null; final String sKey = String.valueOf(key); properties.put(sKey, rb.getObject(sKey)); }/*from w ww . j av a 2s . c o m*/ return properties; }