code.dreamsense.com

XML Property File

We'll take the previous example and make one change to it. Instead of calling store, we'll call storeToXML.

    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.Properties;

    public class Property {

      public static void main(String[] args)
        throws FileNotFoundException, IOException {
        Properties props = new Properties();
        props.put("one", "1");
        props.put("two", "2");
        props.storeToXML(new FileOutputStream("test.properties"),
          "any comment here");
      }

    }
  

Kyle Eggleston
kyle@dreamsense.com
Copyright © 2003 - 2020