Reading from property file containing utf 8 character

前端 未结 4 1381
感动是毒
感动是毒 2020-12-14 17:58

I am reading a property file which consists of a message in the UTF-8 character set.

Problem

The output is not in the appropriate format.

4条回答
  •  有刺的猬
    2020-12-14 18:39

    You should specify the UTF-8 encoding when you construct your FileInputStream object. You can use this constructor:

    new FileInputStream("uinsoaptest.properties", "UTF-8");
    

    If you want to make a change to your JVM so as to be able to read UTF-8 files by default, you will have to change the JAVA_TOOL_OPTIONS in your JVM options to something like this :

    -Dfile.encoding=UTF-8
    

提交回复
热议问题