在java生成一个xml文件中,我设置的编码格式为GBK,为什么生成出来的仍然所UTF-8呢?
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
DOMSource source = new DOMSource(document);
transformer.setOutputProperty(OutputKeys.ENCODING, "GBK");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
File file = new File(mPath + "index.xml");
file.createNewFile();
String filename = file.getAbsolutePath();
PrintWriter pw = new PrintWriter(new FileOutputStream(filename));
StreamResult result = new StreamResult(pw);
transformer.transform(source, result);