java.util.Properties encoding

后端 未结 1 1225
感情败类
感情败类 2021-01-22 13:36

I get different results on two different systems and don\'t know why.

Properties prop = new Properties();
prop.load(new ByteArrayInputStream(input)); //input is          


        
1条回答
  •  伪装坚强ぢ
    2021-01-22 14:25

    Java .properties files are encoded with ISO-8859-1 (Latin-1), NOT UTF-8. All non-Latin-1 characters must be entered by using Unicode escape characters, e.g. \uHHHH.

    An alternative is to use the XML format for properties, which IS UTF-8.

    Source: Javadoc

    Also see this SO question

    And this one

    0 讨论(0)
提交回复
热议问题