public class TestXml {
   
 public void bulidXml() throws FileNotFoundException, IOException{
  //创建根节点
  Element root = new Element("game");
  //添加根节点到文档中
  Document doc = new Document(root);
  
  root.addContent(new Element("gameDesc").setText("aaaa"));
  root.addContent(new Element("gwAddres").setText("19"));
  root.addContent(new Element("ltAddress").setText("女"));
  root.addContent(new Element("czAddress").setText("女"));
  root.addContent(new Element("vipDescAddress").setText("女"));
  root.addContent(new Element("scTitle").setText("女"));
  root.addContent(new Element("scAddress").setText("女"));
  root.addContent(new Element("fcmAddress").setText("女"));
  XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat().setEncoding("UTF-8")); //设置字符集
  xmlOut.output(doc, new FileOutputStream("user.xml"));
  System.out.println(xmlOut.outputString(doc));
  File file = new File("d:/test");
  if(!file.exists()){ // 如果不存在此文件创建文件夹
   file.mkdir();
  }
  File f = new File("d:/test/user.xml"); //创建文件夹中的文件
  if(!f.exists()){
   f.createNewFile();
  }
  //BufferedWriter bw = new BufferedWriter(fw,"");
  OutputStreamWriter ow = new OutputStreamWriter(new FileOutputStream("d:/test/user.xml"),"UTF-8");
  xmlOut.output(doc, ow);
  ow.close();
 }
 public static void main(String[] args) throws FileNotFoundException, IOException {
  TestXml test = new TestXml();
  System.out.println("生成 xml 文件。。。。。");
  test.bulidXml();
 }