How to convert Java Properties file to XML file
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.Properties;
public class PropertyToXML {
public static void main(String[] args) {
try{
Properties property = new Properties();
property.setProperty("designation", "APAC Manager");
property.setProperty("city", "Bangalore");
property.setProperty("state", "Karnataka");
property.setProperty("country", "India");
// XML file path to save
OutputStream os = new FileOutputStream("D://propertiesToXML.xml");
// Write properties into XML
property.storeToXML (os, "Details");
}catch (Exception e) {
e.printStackTrace();
}
}
}
OUTPUT: