How to save Chinese Characters to file with java?

前端 未结 6 1985
小蘑菇
小蘑菇 2020-12-13 22:10

I use the following code to save Chinese characters into a .txt file, but when I opened it with Wordpad, I couldn\'t read it.

StringBuffer Shanghai_StrBuf =          


        
6条回答
  •  [愿得一人]
    2020-12-13 22:54

    Try this,

    StringBuffer Shanghai_StrBuf=new StringBuffer("\u4E0A\u6D77");
        boolean Append=true;
    
        Writer out = new BufferedWriter(new OutputStreamWriter(
            new FileOutputStream(FileName,Append), "UTF8"));
        for (int i=0;i

提交回复
热议问题