xml
用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();
}
}
??
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |