aspose file tools*
The moose likes I/O and Streams and the fly likes How do I read and write text files with different character sets? 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 do I read and write text files with different character sets?" Watch "How do I read and write text files with different character sets?" New topic
Author

How do I read and write text files with different character sets?

Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 689

I need to be able to read and write text files to and from the following character sets: ASCII, ISO-8809-1, MacRoman, and UTF-8.

I have developed the following code which works, but I don't know how to specify the character set.

Will somebody tell me how to modify my code so that the Charset object that is used can be a parameter?




[ September 10, 2008: Message edited by: Kaydell Leavitt ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42946
    
  68
Instead of FileReader -> BufferedReader you'd use FileInputStream -> InputStreamReader -> BufferedReader. The InputStreamReader constructor can take a CharSet as a parameter. It works similarly for output streams instead of a Writer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I read and write text files with different character sets?