List of usage examples for java.util Properties Properties
public Properties()
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 v a 2s.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", "15"); // create a output and input as a xml file FileOutputStream fos = new FileOutputStream("properties.xml"); FileInputStream fis = new FileInputStream("properties.xml"); // store the properties in the specific xml prop.storeToXML(fos, null);/*from w ww.j a v a 2 s .co m*/ // load from the xml that we saved earlier prop.loadFromXML(fis); // print the properties list prop.list(System.out); }
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"); // store the properties in the specific xml prop.storeToXML(fos, "Properties Example"); // print the xml while (fis.available() > 0) { System.out.print((char) fis.read()); }/*from w ww.ja va2 s. c om*/ }
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 ww w . j a v a 2 s. c om*/ p.list(System.out); }
From source file:Main.java
public static void main(String[] args) throws Exception { Properties prop = new Properties(); String s = "Chapter Count=200"; String s2 = "Tutorial Count=15"; // create a new input and output stream FileOutputStream fos = new FileOutputStream("properties.txt"); FileInputStream fis = new FileInputStream("properties.txt"); // write the first property in the output stream file fos.write(s.getBytes());//www . ja va 2 s .c o m // change the line between the two properties fos.write("\n".getBytes()); // write next property fos.write(s2.getBytes()); // load from input stream prop.load(fis); // print the properties list from System.out prop.list(System.out); }
From source file:Main.java
public static void main(String[] args) throws IOException { Properties properties = new Properties(); try (InputStream input = new FileInputStream("test.properties")) { properties.load(input);/*from w w w.java 2 s. co m*/ } for (String key : properties.stringPropertyNames()) { System.out.println(key + " = '" + properties.get(key) + "'"); } }
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());/* w w w. j a va 2s. co m*/ System.out.println("prop1 :\n " + props.get("prop1")); System.out.println("prop2 :\n " + props.get("prop2")); }
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(); String fileName = "app.config"; InputStream is = new FileInputStream(fileName); prop.load(is);//ww w . j a v a 2 s.co m System.out.println(prop.getProperty("app.name")); System.out.println(prop.getProperty("app.version")); System.out.println(prop.getProperty("app.vendor", "Java")); }