Emits an XML document representing all of the properties contained in this table, using the specified encoding.
Program
package com.candidjava;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;
/*
* @author : Mohan
* @description : Emits an XML document representing all of the properties contained in this table, using the specified encoding.
*/
public class PropertiesStoreToXmlEncode {
public static void main(String[] args) {
Properties prop = new Properties();
// add some properties
prop.put("height", "200");
prop.put("level", "15");
prop.put("Event", "33");
try {
// 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 and a different encoding
prop.storeToXML(fos, "Properties Example", "ISO 8859");
// print the xml. Notice that ISO 8859 isn't supported
while (fis.available() > 0) {
System.out.print("" + (char) fis.read());
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
Output
Warning: The encoding 'ISO 8859' is not supported by the Java runtime.
Warning: encoding "ISO 8859" not supported, using UTF-8