用jdom写xml文件
public class App
{
public static void main( String[] args ) throws Exception
{
OutputStream out = new FileOutputStream("d:/customers.xml");
Document document = new Document();
Element root = new Element("customers");
document.setRootElement(root);
for(int i=0;i<10;i++){
Element ec = new Element("customer");
Element namee = new Element("cname");
namee.addContent("fiona"+i);
Element passworde = new Element("password");
passworde.addContent("123"+i);
Element birthe = new Element("birth");
birthe.addContent("1992-10-1"+i);
ec.addContent(namee);
ec.addContent(passworde);
ec.addContent(birthe);
root.addContent(ec);
}
XMLOutputter outputter = new XMLOutputter();
outputter.setFormat(Format.getPrettyFormat());
outputter.output(document, out);
out.close();
}
}