* 參見:
* 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();
延伸閱讀
文章來源于領測軟件測試網 http://www.kjueaiud.com/