* 参见:
* http://www.malcolmhardie.com/weblogs/angus/2004/10/23/java-filewriter-xml-and-utf-8/
*/
public class FileWriterSubstituteSample ...{
public static void main(String[] args)...{
String path="cn/yethyeth/sample/resources/XML_UTF-8.xml";
try ...{
OutputStreamWriter out = new OutputStreamWriter(
new FileOutputStream(path),"UTF-8");
out.write("<?xml version="1.0" encoding="utf-8"?><a>这是测试。</a>");
out.flush();
out.close();
System.out.println("success...");
} catch (UnsupportedEncodingException e) ...{
// TODO Auto-generated catch block
e.printStackTrace();
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/