How to save Chinese Characters to file with java ?

Posted by Frank on Stack Overflow See other posts from Stack Overflow or by Frank
Published on 2009-04-19T23:20:19Z Indexed on 2010/06/14 15:42 UTC
Read the original article Hit count: 240

Filed under:
|
|
|

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

StringBuffer Shanghai_StrBuf=new StringBuffer("\u4E0A\u6D77");
boolean Append=true;

FileOutputStream fos;
fos=new FileOutputStream(FileName,Append);
for (int i=0;i<Shanghai_StrBuf.length();i++) fos.write(Shanghai_StrBuf.charAt(i));
fos.close();

What can I do ? I know if I cut and paste Chinese characters into a wordpad I can save it into a .txt file. How to do that with java ?

© Stack Overflow or respective owner

Related posts about java

Related posts about file