Example usage for java.util Properties put

List of usage examples for java.util Properties put

Introduction

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

Prototype

@Override
    public synchronized Object put(Object key, Object value) 

Source Link

Usage

From source file:Main.java

public static void main(String[] args) {
    System.out.println(System.getProperty("java.runtime.version"));

    Properties p = System.getProperties();
    p.put("java.runtime.version", "Java Runtime 1.6.0");
    System.setProperties(p);//w w w  . ja v  a  2  s . c o m

    System.out.println(System.getProperty("java.runtime.version"));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

    Properties prop = new Properties();
    prop.put("charSet", "iso-8859-7");
    prop.put("user", "your username");
    prop.put("password", "your password");

    // Connect to the database
    Connection con = DriverManager.getConnection("url", prop);

}

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);//ww w  . ja  va  2 s. com

}

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 a2 s.  c  om
}

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 p = new Properties();

    p.put("today", new Date().toString());
    p.put("user", "A");

    FileOutputStream out = new FileOutputStream("user.props");
    p.storeToXML(out, "updated");

    FileInputStream in = new FileInputStream("user.props");

    p.loadFromXML(in);/*from  w  w  w.j a v a2  s .co  m*/
    p.list(System.out);
}

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", "15");
    prop.put("tutorial", "java2s.com");

    // assign the property names in a enumaration
    Enumeration<?> enumeration = prop.propertyNames();

    // print the enumaration elements
    System.out.println(enumeration.nextElement());
    System.out.println(enumeration.nextElement());

}

From source file:MainClass.java

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

    capitals.put("K1", "V1");
    capitals.put("K2", "V2");

    Set states = capitals.keySet();

    for (Object name : states)
        System.out.println("The value of " + name + " is " + capitals.getProperty((String) name) + ".");
}

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", "15");
    prop.put("tutorial", "java2s.com");

    // create a output and input as a xml file
    FileOutputStream fos = new FileOutputStream("properties.xml");
    FileInputStream fis = new FileInputStream("properties.xml");

    prop.storeToXML(fos, "Properties Example", "ISO 8859");

    while (fis.available() > 0) {
        System.out.print((char) fis.read());
    }/*from w  w w.j a  va 2s .c  o  m*/

}