FileInputStream和FileReader
Author
Zhou Renjian
Create@
2006-11-25 03:32
TransformerFactory tFactory = TransformerFactory.newInstance();
//String ebookBase = "F:/jakarta-tomcat-5.0.28/webapps/ROOT/whizzebooks";
Transformer transformer = tFactory
.newTransformer(new StreamSource(new File(XSL_BASE_PATH, "category.xsl")));
transformer.setOutputProperty("encoding", "gb2312");
FileInputStream xml = new FileInputStream(new File(XSL_BASE_PATH, path));
StringWriter html = new StringWriter();
transformer.transform(new StreamSource(xml),
new StreamResult(html));
response.getWriter().write(html.toString());
如果使用FileReader的话,可能在不同的平台上出现乱码现象!
推荐用FileInputStream。