(1) I parsed an XML document containing Chinese characters and got the XML bean as below:
(2) Then I tried to store it in a file as below:
(3) When I open "chineseCharsFile.xml" in a text editor, I'm able to see the Chinese characters, but when I open "newChineseCharsFile.xml" in the same text editor I'm not able to see the Chinese characters.
If you don't specify an encoding when writing files, the platform default encoding will be used - which in all likelihood doesn't support Chinese characters. You can use an OutputStreamWriter wrapped around a FileOutputStream to accomplish this.