I have had similar issues in reading and writing various character encoding types. Below is code snippet of how i create a BufferredWriter (BufferrredWriter in order for efficiency),
The key point is that internally I use a OutputStream (first FileOutputStream and then a OutputStreamWriter). With the OutputStreamWriter I am able to specify an encoding.
Windows by Default uses one encoding (something like cp1252) while linux uses unicode or UTF-8. Anyways, by specifying the encoding as UTF-8 I am able to write out the output in the correct character encoding scheme and the characters look like what they should, which in my case happens to be Chinese pinyin characters (so long a you use a reader that is able to read UTF-8 correctly - In linux mousepad is fine, in windows you can import ito Excel and specify the encoding on the import as UTF-8).
This had the effect of changing my initial output from a bunch of ?'s to the actual characters that I needed to see.
Main Topics
Browse All Topics





by: a_bPosted on 2009-06-17 at 18:25:16ID: 24653938
There is a command line utility called iconv which converts to whatever encoding you want. It works best if you need to convert a whole bunch of files. Before sending out the 500+ emails you can use iconv from your java program and then send it out.