List of usage examples for java.util Properties Properties
public Properties()
From source file:MainClass.java
public static void main(String args[]) throws Exception { Properties p = new Properties(); p.load(new FileInputStream("test.txt")); p.list(System.out);/*from ww w . j a va2 s. c om*/ }
From source file:Main.java
public static void main(String args[]) throws Exception { Properties prop = new Properties(); FileInputStream fis = new FileInputStream("sampleprops.xml"); prop.loadFromXML(fis);// w ww. j a v a 2 s .c o m prop.list(System.out); System.out.println("\nThe foo property: " + prop.getProperty("foo")); }
From source file:PropDemoDef.java
public static void main(String args[]) { Properties defList = new Properties(); defList.put("Florida", "Tallahassee"); defList.put("Wisconsin", "Madison"); Properties capitals = new Properties(defList); 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"); System.out.println("The capital of Florida is " + str + "."); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { Properties p = new Properties(); p.load(new FileInputStream("colon.txt")); p.list(System.out);//w w w.j a v a 2s . c om }
From source file:Main.java
public static void main(String[] args) throws Exception { Properties properties = new Properties(); properties.setProperty("database.type", "mysql"); properties.setProperty("database.url", "jdbc:mysql://localhost/mydb"); properties.setProperty("database.username", "root"); properties.setProperty("database.password", "root"); FileOutputStream fos = new FileOutputStream("database-configuration.xml"); properties.storeToXML(fos, "Database Configuration", "UTF-8"); }
From source file:Main.java
public static void main(String[] args) throws Exception { Properties prop = new Properties(); String s = "Chapter Count=200\nTutorial Count=15"; // create a new reader StringReader reader = new StringReader(s); // load from input stream prop.load(reader);//from ww w .j a va2s . co m // print the properties list from System.out prop.list(System.out); }
From source file:Main.java
public static void main(String[] args) throws Exception { Properties prop = new Properties(); PrintWriter writer = new PrintWriter(System.out); prop.put("Chapter Count", "200"); prop.put("Tutorial Count", "150"); prop.put("tutorial", "java2s.com"); prop.put("Runnable", "true"); // print the list with a PrintWriter object prop.list(writer);/*from w w w . j a va 2 s . c om*/ // flush the stream writer.flush(); }
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:Main.java
public static void main(String[] args) throws Exception { Properties prop = new Properties(); StringWriter sw = new StringWriter(); prop.setProperty("Chapter Count", "200"); prop.put("Tutorial Count", "1500"); prop.put("tutorial", "java2s.com"); // print the list System.out.println(prop);/*from w ww .j a va2 s .c o m*/ // store the properties list in an output writer prop.store(sw, "Main"); System.out.println(sw.toString()); }
From source file:Main.java
public static void main(String args[]) throws Exception { Properties p = new Properties(); p.load(new FileInputStream("test.txt")); p.store(new FileOutputStream("t.txt"), "no comments"); }