This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
(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.