当前位置: 技术问答>java相关
如何正确输出BIG5编码的XML文件
来源: 互联网 发布时间:2015-09-24
本文导语: 我从数据库中读取了一些数据,都是繁体中文的字符串,然后组合成一个DOM Document 最后,用下列代码输出成XML文件 try { domSource = new DOMSource(doc); TransformerFactory tFactory = Transfo...
我从数据库中读取了一些数据,都是繁体中文的字符串,然后组合成一个DOM Document
最后,用下列代码输出成XML文件
try
{
domSource = new DOMSource(doc);
TransformerFactory tFactory = TransformerFactory.newInstance();
// Get a TransformerFactory.
Transformer transformer = tFactory.newTransformer();
// Make a new Transformer from it
Properties properties = transformer.getOutputProperties();
properties.setProperty(OutputKeys.ENCODING,"BIG5");
properties.setProperty(OutputKeys.METHOD,"xml");
transformer.setOutputProperties(properties);
// now proceed with the transformation
int length = filePathes.size();
System.out.println(length);
for (int i=0; i
最后,用下列代码输出成XML文件
try
{
domSource = new DOMSource(doc);
TransformerFactory tFactory = TransformerFactory.newInstance();
// Get a TransformerFactory.
Transformer transformer = tFactory.newTransformer();
// Make a new Transformer from it
Properties properties = transformer.getOutputProperties();
properties.setProperty(OutputKeys.ENCODING,"BIG5");
properties.setProperty(OutputKeys.METHOD,"xml");
transformer.setOutputProperties(properties);
// now proceed with the transformation
int length = filePathes.size();
System.out.println(length);
for (int i=0; i