0

Possible Duplicate:
How to write a UTF-8 file with Java?

I want to create a csv file using java and write into it which supporting UTF-8. How can I do this.?

Community
  • 1
  • 1
Ronak Jain
  • 2,402
  • 2
  • 24
  • 38
  • see http://stackoverflow.com/questions/1001540/how-to-write-a-utf-8-file-with-java – Dan Apr 09 '12 at 13:03

2 Answers2

5
new OutputStreamWriter(new FileOutputStream("path/to/file"), Charset.forName("UTF-8"))
Alexey Berezkin
  • 1,513
  • 1
  • 10
  • 18
1
Writer myWriter= new BufferedWriter(new OutputStreamWriter(
    new FileOutputStream("filename"), "UTF-8"));
try {
    myWriter.write(stringdata);
} catch(Exception e){
e.printStacktrace();
}
Balaswamy Vaddeman
  • 8,360
  • 3
  • 30
  • 40