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:cu.uci.uengine.utils.FileUtils.java

public static boolean dos2unixFileFixer(String filePath) throws IOException, InterruptedException {
    // bash es muy sensible a los cambios de linea \r\n de Windows. Para
    // prevenir que esto cause Runtime Errors, es necesario convertirlos a
    // un sistema comprensible por ubuntu: \n normal en linux. El comando
    // dos2unix hace esto.
    // se lo dejamos a todos los codigos para evitar que algun otro lenguaje
    // tambien padezca de esto

    Properties langProps = new Properties();
    langProps.load(ClassLoader.getSystemResourceAsStream("uengine.properties"));

    String dos2unixPath = langProps.getProperty("dos2unix.path");

    ProcessBuilder pb = new ProcessBuilder(dos2unixPath, filePath);
    Process process = pb.start();
    process.waitFor();//from   w w w.  j av a 2s.  c  om

    return process.exitValue() == 0;
}

From source file:uk.dsxt.voting.common.utils.web.JettyRunner.java

public static Server run(ResourceConfig application, Properties properties, String portPropertyName) {
    Integer port = Integer.valueOf(properties.getProperty(portPropertyName));
    return run(application, properties, port, "*", null, null, null, null, null, false);
}

From source file:de.highbyte_le.weberknecht.Version.java

protected static Version parseProperties(Properties properties) {
    try {//from   w  w  w  .j a v  a  2 s.  c o m
        int major = Integer.parseInt(properties.getProperty("version.weberknecht.major"));
        int minor = Integer.parseInt(properties.getProperty("version.weberknecht.minor"));
        int patch = Integer.parseInt(properties.getProperty("version.weberknecht.patch"));
        String branch = properties.getProperty("version.weberknecht.branch");

        return new Version(major, minor, patch, branch);
    } catch (NumberFormatException e) {
        logger.error("parseProperties() - number format exception: " + e.getMessage());
    }

    return null;
}

From source file:Main.java

public static String getProperty(Context context, String key) {
    try {//from  w  w w  .  j  av a2 s . c o  m
        Properties props = new Properties();
        InputStream input = context.getAssets().open("config.properties");
        if (input != null) {
            props.load(input);
            return props.getProperty(key);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return "";
}

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

private static boolean validateProperties(Properties properties) {
    return properties != null && properties.getProperty(PROP_EXECUTABLE_NAME) != null;
}

From source file:it.geosolutions.geostore.services.rest.auditing.AuditingConfiguration.java

private static String getProperty(Properties properties, String propertyName) {
    String propertyValue = properties.getProperty(propertyName);
    if (propertyValue == null) {
        throw new AuditingException("Missing configuration property '%s'.", propertyName);
    }//w  w w.  j a  v a  2s  .  co  m
    return propertyValue;
}

From source file:Main.java

public static String getProperty(String key, Context context) throws IOException {
    Properties properties = new Properties();
    AssetManager assetManager = context.getAssets();
    InputStream inputStream = assetManager.open("marvel.properties");
    properties.load(inputStream);//w  w  w .  ja v  a 2s .  c  o  m
    return properties.getProperty(key);
}

From source file:cz.lidinsky.editor.Action.java

public static Action getAction(Properties settings, String key)
        throws ClassNotFoundException, InstantiationException, IllegalAccessException {

    // get class name
    String className = settings.getProperty(key + "_action_class");
    // create class
    Class<Action> actionClass = (Class<Action>) Class.forName(className);
    // create instance
    Action action = actionClass.newInstance();
    // set text param
    setLabel(action, settings.getProperty(key + "_action_text"));
    // return action
    return action;
}

From source file:com.linkedin.haivvreo.HaivvreoUtils.java

/**
 * Determine the schema to that's been provided for Avro serde work.
 * @param properties containing a key pointing to the schema, one way or another
 * @return schema to use while serdeing the avro file
 * @throws IOException if error while trying to read the schema from another location
 * @throws HaivvreoException if unable to find a schema or pointer to it in the properties
 *//*from w  w w .  j  ava 2  s. com*/
public static Schema determineSchemaOrThrowException(Properties properties)
        throws IOException, HaivvreoException {
    String schemaString = properties.getProperty(SCHEMA_LITERAL);
    if (schemaString != null && !schemaString.equals(SCHEMA_NONE))
        return Schema.parse(schemaString);

    // Try pulling directly from URL
    schemaString = properties.getProperty(SCHEMA_URL);
    if (schemaString == null || schemaString.equals(SCHEMA_NONE))
        throw new HaivvreoException(EXCEPTION_MESSAGE);

    try {
        if (schemaString.toLowerCase().startsWith("hdfs://"))
            return getSchemaFromHDFS(schemaString, new Configuration());
    } catch (IOException ioe) {
        throw new HaivvreoException("Unable to read schema from HDFS: " + schemaString, ioe);
    }

    return Schema.parse(new URL(schemaString).openStream());
}

From source file:eu.databata.engine.util.PropagatorRecreateDatabaseTool.java

private static String replacePlaceholders(String script, Properties properties) {
    String result = "";
    try {/*  w  w w  .  ja va2 s. c om*/
        result = script.replaceAll("#\\{db.propagation.user\\}", properties.getProperty("db.propagation.user"));
        result = result.replaceAll("#\\{db.propagation.dba.user\\}",
                properties.getProperty("db.propagation.dba.user"));
        result = result.replaceAll("#\\{db.propagation.password\\}",
                properties.getProperty("db.propagation.password"));
    } catch (Exception e) {
        LOG.error("Error occured when replacing placeholders", e);
    }
    return result;
}