java: how to convert a file to utf8

后端 未结 4 1028
一向
一向 2020-12-09 11:42

i have a file that have some non-utf8 caracters (like \"ISO-8859-1\"), and so i want to convert that file (or read) to UTF8 encoding, how i can do it?

The code it\'s

4条回答
  •  囚心锁ツ
    2020-12-09 11:59

    You only want to read it as UTF-8? What I did recently given a similar problem is to start the JVM with -Dfile.encoding=UTF-8, and reading/printing as normal. I don't know if that is applicable in your case.

    With that option:

    System.out.println("á é í ó ú")
    

    prints correctly the characters. Otherwise it prints a ? symbol

提交回复
热议问题