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, String defaultValue) 

Source Link

Document

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

Usage

From source file:it.geosolutions.geobatch.jetty.Start.java

private static WebAppContext configureContext(final Properties prop) {
    WebAppContext wah = new WebAppContext();

    wah.setContextPath(prop.getProperty(CONTEXT_PATH, CONTEXT_PATH_DEFAULT));
    wah.setWar(prop.getProperty(WAR_PATH, WAR_PATH_DEFAULT));
    wah.setTempDirectory(new File(prop.getProperty(TEMP_DIR, TEMP_DIR_DEFAULT)));
    return wah;/*from   w w  w. j a v  a2  s .  com*/
}

From source file:com.amazonaws.services.kinesis.multilang.MultiLangDaemonConfig.java

private static int getMaxActiveThreads(Properties properties) {
    return Integer.parseInt(properties.getProperty(PROP_MAX_ACTIVE_THREADS, "0"));
}

From source file:com.dotmarketing.util.UpdateUtil.java

/**
 * @return the new version if found. Null if up to date.
 * @throws DotDataException if an error is encountered
 *///from   www.  ja  va2 s.c o  m
public static String getNewVersion() throws DotDataException {

    //Loading the update url
    Properties props = loadUpdateProperties();
    String fileUrl = props.getProperty(Constants.PROPERTY_UPDATE_FILE_UPDATE_URL, "");

    Map<String, String> pars = new HashMap<String, String>();
    pars.put("version", ReleaseInfo.getVersion());
    //pars.put("minor", ReleaseInfo.getBuildNumber() + "");
    pars.put("check_version", "true");
    pars.put("level", System.getProperty("dotcms_level"));
    if (System.getProperty("dotcms_license_serial") != null) {
        pars.put("license", System.getProperty("dotcms_license_serial"));
    }

    HttpClient client = new HttpClient();

    PostMethod method = new PostMethod(fileUrl);
    Object[] keys = (Object[]) pars.keySet().toArray();
    NameValuePair[] data = new NameValuePair[keys.length];
    for (int i = 0; i < keys.length; i++) {
        String key = (String) keys[i];
        NameValuePair pair = new NameValuePair(key, pars.get(key));
        data[i] = pair;
    }

    method.setRequestBody(data);
    String ret = null;

    try {
        client.executeMethod(method);
        int retCode = method.getStatusCode();
        if (retCode == 204) {
            Logger.info(UpdateUtil.class, "No new updates found");
        } else {
            if (retCode == 200) {
                String newMinor = method.getResponseHeader("Minor-Version").getValue();
                String newPrettyName = null;
                if (method.getResponseHeader("Pretty-Name") != null) {
                    newPrettyName = method.getResponseHeader("Pretty-Name").getValue();
                }

                if (newPrettyName == null) {
                    Logger.info(UpdateUtil.class, "New Version: " + newMinor);
                    ret = newMinor;
                } else {
                    Logger.info(UpdateUtil.class, "New Version: " + newPrettyName + "/" + newMinor);
                    ret = newPrettyName;
                }

            } else {
                throw new DotDataException(
                        "Unknown return code: " + method.getStatusCode() + " (" + method.getStatusText() + ")");
            }
        }
    } catch (HttpException e) {
        Logger.error(UpdateUtil.class, "HttpException: " + e.getMessage(), e);
        throw new DotDataException("HttpException: " + e.getMessage(), e);

    } catch (IOException e) {
        Logger.error(UpdateUtil.class, "IOException: " + e.getMessage(), e);
        throw new DotDataException("IOException: " + e.getMessage(), e);
    }

    return ret;
}

From source file:Main.java

public static boolean getProperty(String filePath, String fileName, Map<String, String> propertyMap) {
    try {/* w  w w .j a v a  2 s  . c o m*/
        Properties p = loadPropertyInstance(filePath, fileName);
        for (String name : propertyMap.keySet()) {
            propertyMap.put(name, p.getProperty(name, propertyMap.get(name)));
        }
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}

From source file:com.amazonaws.hbase.kinesis.KinesisConnectorExecutor.java

/**
 * Helper method used to parse integer properties.
 * /*from  w w w.j  a  v a2 s  . co  m*/
 * @param property
 *        The String key for the property
 * @param defaultValue
 *        The default value for the integer property
 * @param properties
 *        The properties file to get property from
 * @return property from property file, or if it is not specified, the default value
 */
private static int parseInt(String property, int defaultValue, Properties properties) {
    return Integer.parseInt(properties.getProperty(property, Integer.toString(defaultValue)));
}

From source file:com.amazonaws.hbase.kinesis.KinesisConnectorExecutor.java

/**
 * Helper method used to parse boolean properties.
 * /*from www.  j  a  v  a2 s  .c om*/
 * @param property
 *        The String key for the property
 * @param defaultValue
 *        The default value for the boolean property
 * @param properties
 *        The properties file to get property from
 * @return property from property file, or if it is not specified, the default value
 */
private static boolean parseBoolean(String property, boolean defaultValue, Properties properties) {
    return Boolean.parseBoolean(properties.getProperty(property, Boolean.toString(defaultValue)));
}

From source file:com.madgag.agit.GitTestUtils.java

public static String gitServerHostAddress() throws IOException, FileNotFoundException, UnknownHostException {
    File bang = new File(Environment.getExternalStorageDirectory(), "agit-integration-test.properties");
    Properties properties = new Properties();
    if (bang.exists()) {
        properties.load(new FileReader(bang));
    }/*  w  w  w.  j ava2  s. c  o m*/
    String hostAddress = properties.getProperty("gitserver.host.address", "10.0.2.2");
    InetAddress address = InetAddress.getByName(hostAddress);
    assertThat("Test gitserver host " + hostAddress + " is reachable", address.isReachable(1000), is(true));
    return hostAddress;
}

From source file:Main.java

public static String getBuildProp(String propertyName) {
    Properties buildProps = new Properties();
    try {//  w w w  .j a v  a2s . c  o m
        FileInputStream is = new FileInputStream(new File(BUILD_PROP));
        buildProps.load(is);
        is.close();
        return buildProps.getProperty(propertyName, "");
    } catch (IOException e) {
        logError(e);
    }
    return "";
}

From source file:Main.java

public static String getProperty(String path, String key) {
    Properties prop = new Properties();
    InputStream input = null;//from   w  w  w  .  j  a v  a 2 s.c  o  m
    String output = "";
    try {
        input = new FileInputStream(path);
        prop.load(input);
        output = prop.getProperty(key, "");
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        if (input != null) {
            try {
                input.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
    return output;
}

From source file:dk.alexandra.fresco.suite.spdz.configuration.SpdzConfiguration.java

static SpdzConfiguration fromCmdLine(SCEConfiguration sceConf, CommandLine cmd) throws ParseException {
    Properties p = cmd.getOptionProperties("D");
    //TODO: Figure out a meaningful default for the below 
    final int maxBitLength = Integer.parseInt(p.getProperty("spdz.maxBitLength", "64"));
    if (maxBitLength < 2) {
        throw new ParseException("spdz.maxBitLength must be > 1");
    }//from ww  w  . ja  v  a 2  s  . c  o m
    final String triplePath = p.getProperty("spdz.triplePath", "/triples");
    final boolean useDummyData = Boolean.parseBoolean(p.getProperty("spdz.useDummyData", "False"));

    return new SpdzConfiguration() {

        @Override
        public String getTriplePath() {
            return triplePath;
        }

        @Override
        public int getMaxBitLength() {
            return maxBitLength;
        }

        @Override
        public boolean useDummyData() {
            return useDummyData;
        }
    };
}