import java.io.FileOutputStream;import java.io.IOException;import java.io.OutputStreamWriter;import org.jdom.Attribute;import org.jdom.Document;import org.jdom.Element;import org.jdom.output.Format;import org.jdom.output.XMLOutputter;public class CreateXML {public void create(){Element root=new Element("PEOPLE");Document doc=new Document(root);Element person=new Element("PERSON");root.addContent(person);Attribute attribute=new Attribute("title","這是一個測試的文字");person.setAttribute(attribute);XMLOutputter output=new XMLOutputter(Format.getPrettyFormat().setEncoding("utf-8"));try {//FileWriter writer=new FileWriter("src/people.xml");OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream("src/people.xml"), "UTF-8");output.output(doc, writer);writer.close();} catch (IOException e) {e.printStackTrace();}}public static void main(String[] args) {new CreateXML().create();}}