Java Properties .storeToXML (OutputStream os, String comment, String encoding)
Syntax
Properties.storeToXML(OutputStream os, String comment, String encoding) has the following syntax.
public void storeToXML(OutputStream os, String comment, String encoding) throws IOException
Example
In the following code shows how to use Properties.storeToXML(OutputStream os, String comment, String encoding) method.
//w w w . j a v a 2 s . co m
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;
public class Main {
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());
}
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »