xml
2015-07-29 16:05
253 查看
用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();
}
}
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();
}
}
相关文章推荐
- supervisor 启动redis服务
- Mycat ERROR 1064 (HY000): bad insert sql
- String的拼接和常量池
- Android 签名+混淆( 签名+proguard.cfg)
- svn基本操作
- 错误:Unsupported major.minor version 51.0(jdk版本错误)
- JavaScript_判断浏览器种类IE、FF、Opera、Safari、chrome及版本
- android开发 Edittext编辑框超出屏幕
- Office 365系列之十五:配置Outlook MAPI方式连接Exchange Online
- Office 365系列之十五:配置Outlook MAPI方式连接Exchange Online
- 7月29日 微软宣布Win10商店已向开发者正式开放
- java工作半年总结(反射)
- 常见面试题
- spring中各个jar包的作用
- NYOJ-757-期末考试
- ToggleButton(按钮开关)
- 配置spring文件时候出现的小问题
- arm指令中mov和ldr的区别
- 搭建SSH框架顺序和注意事项
- oracle——表修改语句集合