I need help on reading and writing of Chinese characters encoded as UTF-8(but they are not in the u\xxxx) format. If you open it in Notpad, you will be able to view the chinese writings in it. What I need to do is read thru the file(saving the data in ArrayLists and VO's) and rewrite it down to a new file. The problem is after I read the file, do the operations and write the file to disk, I'm not able to view the characters as chinese anymore. Please help... I really need this.
What I need to do is read thru the file(saving the data in ArrayLists and VO's) and rewrite it down to a new file.
Is your goal just to rewrite the data to a new file, or are you doing some other processing too? That is, do you need to save the data in an ArrayList for some reason?
If you just need to transfer from file to file, I recommend using FileInputStream and FileOutputStream only. Just write the raw bytes from one stream to the other. Or use FileChannel's transferTo() method.
But if you need to do some other processing which requires you to convert the data to Strings, then I'd do something like this:
In order to convert bytes in a file to chars or Strings, you need the InputStreamReader and OutputStreamWriter to correctly specify the encoding to be used. (Unless you're using JDK 1.5, which has some enhancements to FileReader and FileWriter which will help you.)
"I'm not back." - Bill Harding, Twister
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop