JAR包:jdom.jar
Element license_write_root = null;
Document license_write_doc = null;
license_write_root = new Element ("根节点名称"); //创建License文件的根节点
license_write_doc = new Document(license_write_root);
Element license_fileHeader = new Element("子节点名称");
license_fileHeader.setAttribute("属性name","属性值"); //增加属性
license_write_root.addContent(license_fileHeader); //添加子节点
//输出有格式的XML文件
XMLOutputter XMLOut = new XMLOutputter();
Format format = Format.getPrettyFormat(); // 格式化文档
format.setEncoding("UTF-8"); // 设置编码格式为utf-8
XMLOut.setFormat(format);
XMLOut.output(license_write_doc, new FileOutputStream("文件输出路径"));