巧用JDOM中的XMLOutputter类转换XML文件的编码类型 :: 我的文档
来源: BlogBus 原始链接: http://www.blogbus.com:80/blogbus/blog/diary.php?diaryid=449597 存档链接: https://web.archive.org/web/20050109015032id_/http://www.blogbus.com:80/blogbus/blog/diary.php?diaryid=449597
我的文档 我的第一个Blog,测试功能,编写自己的文档等、日记,以及学习心得等。 <<<使用JDBC存取ORACLE中的LONG类型的数据 | 首页 | MySql中的中文乱码解决方案>>> 巧用JDOM中的XMLOutputter类转换XML文件的编码类型 时间: 2004-10-18 XML文件的编码不同,使用有的编辑器打开时,其中的中文经常会出现乱码.如何解决这个问题呢?下面我将讲一下如何使用JDOM中的XMLOutputter类进行转换XML文件的编码. 使用XMLOutputter转换XML文件的编码例子代码片断 SAXBuilder builder = new SAXBuilder(); Document doc; Format format = Format.getPrettyFormat(); format.setEncoding("GB2312"); XMLOutputter outputter = new XMLOutputter(); outputter.setFormat(format); File file = new File(realPath); doc = builder.build(file); String xmlString = outputter.outputString(doc); liwpstephen 发表于 2004-10-18 21:51 引用(Trackback0) | 编辑 评论 发表评论 最后更新 ErrorPage Example MySql中的中文乱码解决方案 捕获页面中按键操作的工具函数 第四代时间管理 Oracle数据库问题解决方案 See what Jesus says about who is responsible for our suffering 第四种感情 Understanding Classloaders: log4j in a J2EE Environment Build Flexible Logs With log4j 日志设施与通用实现