Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to write chinese character to a text file

843838Apr 9 2007 — edited Apr 11 2007
Hi experts,

I have been searching alot on this topic but none can solve my problem.

My problem is:
I have a string that contains both latin words and chinese characters that was input by the user.
I need to write this string to a text file. However, the chinese character always appear rubbish in my text file.

My code:
String text = "string containing latin and chinese character";
FileWriter fw = new FileWriter("abc.txt");
BufferedWriter bw = new BufferedWriter(fw);
bw.write(text);
bw.close();

Pls advise on how it should be done. Will appreciate if you can show me the code.

A million thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 9 2007
Added on Apr 9 2007
8 comments
1,489 views