Example usage for java.util Properties getProperty

List of usage examples for java.util Properties getProperty

Introduction

In this page you can find the example usage for java.util Properties getProperty.

Prototype

public String getProperty(String key) 

Source Link

Document

Searches for the property with the specified key in this property list.

Usage

From source file:gov.nih.nci.cagrid.caarray.stubs.cql.CaArrayCQLQueryProcessor.java

private static synchronized CaArraySearchService getSearchService() {
    try {/*from w w  w.  java2s.com*/
        final Properties jndiProp = new Properties();
        jndiProp.load(CaArraySvcImpl.class.getResourceAsStream("/gov/nih/nci/cagrid/caarray/jndi.properties"));

        if (jndiProp.getProperty("java.naming.factory.initial") == null
                || jndiProp.getProperty("java.naming.factory.url.pkgs") == null
                || jndiProp.getProperty("java.naming.provider.url") == null) {
            throw new IllegalArgumentException(
                    "Unable to find all required properties in jndi.properties file.");
        }

        final Context context = new InitialContext(jndiProp);
        searchService = (CaArraySearchService) context.lookup(CaArraySearchService.JNDI_NAME);
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
    return searchService;
}

From source file:de.uzk.hki.da.grid.CTIrodsCommandLineConnector.java

@BeforeClass
public static void setUpBeforeClass() throws Exception {

    Properties properties = readProperties();
    zone = properties.getProperty("irods.zone");
}

From source file:Main.java

public static void loadHashMapData() throws IOException {
    HashMap<String, String> hashMap = new HashMap<String, String>();
    Properties properties = new Properties();

    File file = new File(HASHMAPFILEPATH);
    if (file.exists()) {
        properties.load(new FileInputStream(HASHMAPFILEPATH));

        for (String key : properties.stringPropertyNames()) {
            hashMap.put(key, properties.getProperty(key));
            GPSDataMap = hashMap;//from ww w .ja va2s.co  m
        }
    } else {
        file.createNewFile();
    }
}

From source file:com.izforge.izpack.util.LogUtils.java

private static void mergeLoggingConfiguration(Properties to, Properties from) {
    for (String fromName : from.stringPropertyNames()) {
        String fromValue = from.getProperty(fromName);
        if (fromName.matches("\\.?handlers") && to.containsKey(fromName)) {
            String oldValue = to.getProperty(fromName);
            if (!fromValue.equals(oldValue)) {
                to.setProperty(fromName, oldValue + ", " + fromValue);
            }//from w  w w.  j  a va 2s  .  c o m
            continue;
        }
        if (!to.containsKey(fromName)) {
            to.setProperty(fromName, fromValue);
        }
    }
}

From source file:com.navercorp.pinpoint.collector.config.CollectorConfiguration.java

protected static int readInt(Properties properties, String propertyName, int defaultValue) {
    final String value = properties.getProperty(propertyName);
    final int result = NumberUtils.toInt(value, defaultValue);
    if (LOGGER.isInfoEnabled()) {
        LOGGER.info("{}={}", propertyName, result);
    }/*from ww  w.j  a  v  a2 s . co  m*/
    return result;
}

From source file:com.navercorp.pinpoint.collector.config.CollectorConfiguration.java

protected static long readLong(Properties properties, String propertyName, long defaultValue) {
    final String value = properties.getProperty(propertyName);
    final long result = NumberUtils.toLong(value, defaultValue);
    if (LOGGER.isInfoEnabled()) {
        LOGGER.info("{}={}", propertyName, result);
    }//from   w  ww.  ja  va 2 s .c  o m
    return result;
}

From source file:de.dfki.resc28.ole.bootstrap.App.java

public static String getProperty(java.util.Properties p, String key, String sysKey) {
    String value = System.getProperty(sysKey);
    if (value != null) {
        return value;
    }// w  ww  . j a  v  a  2  s .c om
    return p.getProperty(key);
}

From source file:gobblin.source.extractor.extract.kafka.ConfigStoreUtils.java

public static Optional<String> getConfigStoreUri(Properties properties) {
    Optional<String> configStoreUri = StringUtils
            .isNotBlank(properties.getProperty(ConfigurationKeys.CONFIG_MANAGEMENT_STORE_URI))
                    ? Optional.of(properties.getProperty(ConfigurationKeys.CONFIG_MANAGEMENT_STORE_URI))
                    : Optional.<String>absent();
    if (!Boolean.valueOf(properties.getProperty(ConfigurationKeys.CONFIG_MANAGEMENT_STORE_ENABLED,
            ConfigurationKeys.DEFAULT_CONFIG_MANAGEMENT_STORE_ENABLED))) {
        configStoreUri = Optional.<String>absent();
    }/*from w ww  . j a  va2  s  .co  m*/
    return configStoreUri;
}

From source file:com.geekcap.javaworld.sparkexample.proxy.CustomClientBuilder.java

private static String loadVersion() {
    String userAgent = "Hosebird-Client";
    try {//from   w  w  w.  j av a2  s .c  o m
        InputStream stream = ClientBuilder.class.getClassLoader().getResourceAsStream("build.properties");
        try {
            Properties prop = new Properties();
            prop.load(stream);

            String version = prop.getProperty("version");
            userAgent += " " + version;
        } finally {
            stream.close();
        }
    } catch (IOException ex) {
        // ignore
    }
    return userAgent;
}

From source file:com.autentia.tnt.version.Version.java

public static Version getApplicationVersion() {
    if (appVersion == null) {
        try {/*from ww w  . j  a  v a 2s . co m*/
            InputStream is = Thread.currentThread().getContextClassLoader()
                    .getResourceAsStream("com/autentia/tnt/version/info.properties");
            Properties props = new Properties();
            props.load(is);

            appVersion = new Version(props.getProperty("number"));
        } catch (Exception e) {
            log.fatal("static - cannot read version", e);
        }
    }

    return appVersion;
}