当使用TransformerFactory输出时,可设置通过设置OutputProperty的"encoding"为GBK.
TransformerFactory transformerFactory =
TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty("encoding","GBK");
当使用StringReader作为输入时,要注意再次读取时要设置in.reset().
TransformerFactory transformerFactory =
TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty("encoding","GBK");
当使用StringReader作为输入时,要注意再次读取时要设置in.reset().