This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes How to write to a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "How to write to a file" Watch "How to write to a file" New topic

How to write to a file

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9952


I want to write to a file using the Charset API/UTF-8 encoding format. Basically I have a StringBuffer whose contents are in html/ASCII format. I want to use the Charset API and convert this to UTF-8 format and then write the o/p to a file. Any ideas on how to do this?

SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42958
If the data is in ASCII, then you don't need to do any conversion - ASCII is a subset of Unicode. Just specify UTF-8 as encoding when writing the data to the file, and you should be all set.
Have you checked out Aspose?
subject: How to write to a file
jQuery in Action, 3rd edition