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 void main(String[] args) throws Exception {
    Properties defaultPro = new Properties();

    Properties pro = new Properties(defaultPro);

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Properties prop = new Properties();

    prop.put("Chapter Count", "200");
    prop.put("Tutorial Count", "150");
    prop.put("tutorial", "java2s.com");
    prop.put("Runnable", "true");

    // print the list with System.out
    prop.list(System.out);/*  www  .  j av  a 2  s  .  c o m*/

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Properties prop = new Properties();

    prop.put("Chapter Count", "200");
    prop.put("Tutorial Count", "150");
    prop.put("tutorial", "java2s.com");
    prop.put("Runnable", "true");

    // get two properties and print them
    System.out.println(prop.getProperty("Runnable", "false"));
    System.out.println(prop.getProperty("Tutorial Count", "150"));

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Properties prop = new Properties();

    prop.put("Chapter Count", "200");
    prop.put("Tutorial Count", "150");
    prop.put("tutorial", "java2s.com");
    prop.put("Runnable", "true");

    // get two properties and print them
    System.out.println(prop.getProperty("Runnable"));
    System.out.println(prop.getProperty("Tutorial Count"));

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Properties prop = new Properties();

    prop.setProperty("Chapter Count", "200");
    prop.put("Tutorial Count", "1500");
    prop.put("tutorial", "java2s.com");

    // print the list
    System.out.println(prop);/*w  w w  .  j a v  a2 s  .com*/

    // store the properties list in an output stream
    prop.store(System.out, "Main");

}

From source file:Main.java

public static void main(String[] args) {
    Properties prop = new Properties();

    prop.put("Chapter Count", "200");
    prop.put("Tutorial Count", "15");
    prop.put("tutorial", "java2s.com");

    // save the Property names in the set
    Set<String> set = prop.stringPropertyNames();

    System.out.println(set);/*  w ww. j a v a2s  .c  om*/
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Properties prop = new Properties();

    prop.setProperty("Chapter Count", "200");
    prop.put("Tutorial Count", "1500");
    prop.put("tutorial", "java2s.com");

    // print the list
    System.out.println(prop);/*ww w  .ja v  a2 s . c om*/

    // change the properties
    prop.setProperty("Tutorial Count", "15");
    prop.setProperty("Chapter Count", "500");

    // print the list
    System.out.println(prop);
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    Properties props = new Properties();
    URL url = ClassLoader.getSystemResource("props.properties");
    props.load(url.openStream());//from w  w w .  j a  v a  2  s.  co m
    System.out.println("prop1 :\n " + props.get("prop1"));
    System.out.println("prop2 :\n " + props.get("prop2"));
}

From source file:Load.java

public static void main(String args[]) throws Exception {
    Properties p = new Properties();
    p.load(new FileInputStream("colon.txt"));
    p.getProperty("foo");
}

From source file:PropDemo.java

public static void main(String args[]) {
    Properties capitals = new Properties();

    capitals.put("Illinois", "Springfield");
    capitals.put("Missouri", "Jefferson City");
    capitals.put("Washington", "Olympia");
    capitals.put("California", "Sacramento");
    capitals.put("Indiana", "Indianapolis");

    Set states = capitals.keySet();

    for (Object name : states)
        System.out.println(name + " / " + capitals.getProperty((String) name));

    String str = capitals.getProperty("Florida", "Not Found");
    System.out.println("The capital of Florida is " + str + ".");
}