jdom怎么修改 编码为gb2312 ?????
<?xml version="1.0" encoding="UTF-8"?>
默认是这个,怎么改成gb2312
import org.jdom.*;
import org.jdom.output.*;
import org.jdom.input.*;
import java.io.*;
public class TestJDOM{
public static void main(String args[])throws Exception{
SAXBuilder sb = new SAXBuilder();
Document doc = sb.build(new FileInputStream("../A.xml"));
Element root = doc.getRootElement();
java.util.List _menu = root.getChildren();
Element item = (Element)_menu.get(0);
item.setAttribute("typeID","aaa");
XMLOutputter outp = new XMLOutputter();
outp.output(doc, new FileOutputStream("../A.xml"));
}
}
==============================A.xml========================
<?xml version="1.0" encoding="UTF-8"?>
<menu TotalDB="30">
<item typeID="aaa" OperatorID="" SubID="" Time="" />
</menu>
<?xml version="1.0" encoding="UTF-8"?>
默认是这个,怎么改成gb2312
import org.jdom.*;
import org.jdom.output.*;
import org.jdom.input.*;
import java.io.*;
public class TestJDOM{
public static void main(String args[])throws Exception{
SAXBuilder sb = new SAXBuilder();
Document doc = sb.build(new FileInputStream("../A.xml"));
Element root = doc.getRootElement();
java.util.List _menu = root.getChildren();
Element item = (Element)_menu.get(0);
item.setAttribute("typeID","aaa");
XMLOutputter outp = new XMLOutputter();
outp.output(doc, new FileOutputStream("../A.xml"));
}
}
==============================A.xml========================
<?xml version="1.0" encoding="UTF-8"?>
<menu TotalDB="30">
<item typeID="aaa" OperatorID="" SubID="" Time="" />
</menu>
刚才写错了!