How to convert Java Properties file to XML file


Convert Java Properties file to XML file

In our earlier tutorial we have seen how to convert XML file to properties file. As a vice verse we will see how to convert XML file to java properties file in this tutorial. Lets consider there are property key with designation, city, state and country as same as previous tutorial example. Lets try to create same XML file using java properties file in below example code,

import java.util.Properties;

public class PropertyToXML {
 public static void main(String[] args) {
   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) {


No comments:
Write comments