Reading from property file containing utf 8 character

前端 未结 4 1391
感动是毒
感动是毒 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:31

    Use props.load(new FileReader("uinsoaptest.properties")) instead. By default it uses the encoding Charset.forName(System.getProperty("file.encoding")) which can be set to UTF-8 with System.setProperty("file.encoding", "UTF-8") or with the commandline parameter -Dfile.encoding=UTF-8.

提交回复
热议问题