Example usage for java.util Properties Properties

List of usage examples for java.util Properties Properties

Introduction

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

Prototype

public Properties() 

Source Link

Document

Creates an empty property list with no default values.

Usage

From source file:Main.java

public static Properties getProperties(Context context) {
    Properties props = new Properties();
    //      InputStream in = Utils.class.getResourceAsStream("/gewara.properties");
    try {//  w w w .  ja  v  a2  s .co m
        InputStream in = context.getAssets().open("gewara.properties");
        props.load(in);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return props;
}

From source file:Main.java

public static Properties loadConfig(Context context, String file) {
    Properties properties = new Properties();
    try {//w w w.j a  va 2  s.  c o  m
        FileInputStream s = new FileInputStream(file);
        properties.load(s);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return properties;
}

From source file:Main.java

public static Properties extractProperties(Node node) {
    Properties props = new Properties();
    NamedNodeMap attributes = node.getAttributes();
    if (attributes != null) {
        for (int i = 0; i < attributes.getLength(); i++) {
            Node item = attributes.item(i);
            props.put(item.getNodeName(), item.getNodeValue());
        }// w  w  w .j a v a2  s .com
    }
    return props;
}

From source file:Main.java

public static Properties getConfigProperties(Context context) {
    Properties properties = new Properties();
    try {//from   w w w. j a v a2s.  co m
        properties.load(context.getAssets().open("config.properties"));
    } catch (IOException e) {
        e.printStackTrace();
    }
    return properties;
}

From source file:Main.java

public static Properties convertResourceBundleToProperties(ResourceBundle resource) {
    Properties properties = new Properties();

    Enumeration<String> keys = resource.getKeys();
    while (keys.hasMoreElements()) {
        String key = keys.nextElement();
        properties.put(key, resource.getString(key));
        //System.out.println("key: '" + key + "' value: '" + properties.get(key) + "'");
    }/*from w  w w. j a  v  a2 s .  c o m*/

    return properties;
}

From source file:Main.java

/**
 * Read config file./*from w w  w  .j  a va  2s  . c  om*/
 */
private static Properties loadConfig() {
    Properties properties = new Properties();
    try {
        FileInputStream s = new FileInputStream(CONFIG_FILE_PATH);
        properties.load(s);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return properties;
}

From source file:Main.java

public static Properties loadProperties(Context context, String file, String encode) throws Exception {
    Properties properties = new Properties();
    FileInputStream s = new FileInputStream(file);
    properties.load(s);//from  w w w. j  a  v a 2 s .co m
    return properties;
}

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);//from ww  w .ja  v a 2 s.  c  o m
    return properties.getProperty(key);
}

From source file:Main.java

public static Connection getConnection(String dbURL, String user, String password)
        throws SQLException, ClassNotFoundException {
    Class.forName("com.mysql.jdbc.Driver");

    Properties props = new Properties();
    props.put("user", user);
    props.put("password", password);

    props.put("autoReconnect", "true");

    return DriverManager.getConnection(dbURL, props);
}

From source file:Main.java

public static String getProperty(String path, String key) {
    Properties prop = new Properties();
    InputStream input = null;//from   w w  w  .  jav  a 2s . c  om
    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;
}