aspose file tools
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: 9763


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: 42954
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.
It is sorta covered in the JavaRanch Style Guide.
subject: How to write to a file