Store Java properties as XML file.

Added on 10/12/2009 5:10:07 PM by Unknown(Google)
This code example shows how to store Java Properties names, values into XML file.
Properties properties = new Properties();

properties.setProperty("name1", "value1");
properties.setProperty("name2", "value2");
properties.setProperty("name3", "value3");

FileOutputStream fos = new FileOutputStream("output.xml");
properties.storeToXML(fos, "Name-Values", "UTF-8");

The XML output:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>Name-Values</comment>
<entry key="name1">value1</entry>
<entry key="name2">value2</entry>
<entry key="name3">value3</entry>
</properties>

Attachment

No Attachments.

Comments

There are no comments for this code snippet.

Add Comment



Language:



Code:

Image Title:



Image URL:

Code Bold Italic Link <br /> Clear

Ranking

  • 4.0/2
    Rank 5 (High) Rank 4 Rank 3 Rank 2 Rank 1 (Low)

Books you might like.

  • Sams Teach Yourself Java in 24 Hours

Share

  • Bookmark and Share