This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara 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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "How to write to a file" Watch "How to write to a file" New topic
Author

How to write to a file

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9353
    
    2

Guys,

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
Marshal

Joined: Mar 22, 2005
Posts: 41633
    
  55
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.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to write to a file