The following program will create a XML file and write it intto disk.
import org.jdom.*;
import org.jdom.output.XMLOutputter;
import java.util.*;
import java.io.*;
public class repository
{
public static void main(String[] args)
{
Element root = new Element("repositories");
Document doc = new Document(root);
Element foo = new Element("repository1");
foo.setText("www.iiitmk.ac.in");
root.addContent(foo);
Element bar = new Element("repository2");
bar.setText("www.rajiv.com.");
root.addContent(bar);
try{
XMLOutputter outputter = new XMLOutputter();
FileOutputStream out = new FileOutputStream("repository.xml");
outputter.output(doc, out);
out.flush();
out.close();
}
catch (java.io.IOException e){
e.printStackTrace();
}
}
}
0 Comments:
Post a Comment
<< Home