1

I use apache common fileutils library and I want to export my strings to a csv file. When I write them to csv file it gives charset error for example: if I write "türkiye" , csv file shows it like this:"türkiye", I tried utf-8 but it didn't work can u helpme here is my code:

String cset = "utf-8";

    FileUtils.writeStringToFile(new File("C:/---/output.csv"), stringBuilder.toString(),
            Charset.forName(cset));

}
Fatih Aktepe
  • 501
  • 1
  • 10
  • 18
  • How are you opening the csv file? Please note that if you are opening it with notepad (The default Windows editor) it doesn't support UTF characters AFAIK, so you'll need another editor. – BackSlash Aug 13 '15 at 12:41
  • I don't open csv file. I create it with the process. When I call the code above it creates the file automatically. – Fatih Aktepe Aug 13 '15 at 12:46
  • 1
    I meant, how do you open the file to check its contents? _After_ you write to it with `FileUtils`, how are you opening it to see `türkiye` instead of `türkiye`? Are you using some program? Is it the default Windows notepad? – BackSlash Aug 13 '15 at 12:48
  • I open it with excel – Fatih Aktepe Aug 13 '15 at 13:06
  • That string looks like what you get if the program you are using to read the file does not understand that the file is UTF-8. See [this question](https://stackoverflow.com/questions/6002256/is-it-possible-to-force-excel-recognize-utf-8-csv-files-automatically) for details about telling Excel that your file is UTF-8 – greg-449 Aug 13 '15 at 13:12
  • thanks it helped much – Fatih Aktepe Aug 13 '15 at 14:54

0 Answers0