Properties: storeToXML(OutputStream os, String comment) : Properties « java.util « Java by API






Properties: storeToXML(OutputStream os, String comment)

 
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Date;
import java.util.Properties;

public class Main {
  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);
    p.list(System.out);
  }
}

   
  








Related examples in the same category

1.new Properties()
2.new Properties(Properties prop)
3.Properties: getProperty(String key)
4.Properties: getProperty(String key, String defaultValue)
5.Properties: list(PrintStream out)
6.Properties: load(InputStream inStream)
7.Properties: loadFromXML(InputStream in)
8.Properties: keySet()
9.Properties: propertyNames()
10.Properties: setProperty(String key, String value)
11.Properties: store(OutputStream out, String comments)