This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unicode problem in HTMLEditorKit

 
Stephen Lee
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My program use StringWriter to get the unicode in a HTMLEditorKit by this code:
Writer textOut = new StringWriter();
htmlEditorkit.write(str, doc, start, end);
The string I got from this method is in the format of decimal unicode (e.g. 雅). Actually, I do not mind that it is in this format. However, I need to save this string into a file with the format of UTF-8. I have tried to use the following codes:
FileOutputStream fos = new FileOutputStream(new File(fileName));
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
out.write(str);
...
However, the content in the file saved is still in the format of decimal unicode.
How can I get the file with the content in the UTF-8? Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic