获取properties文件中的

1、配置文件

 2、配置文件内容

 3、测试代码

public class Test {
    public static void main(String[] args) throws UnsupportedEncodingException {

        Locale locale = Locale.getDefault();
        ResourceBundle bundle = ResourceBundle.getBundle("label", locale);
        String xm = bundle.getString("xm");
        String gb = bundle.getString("gb");
        //防止中文乱码
        String xmm = new String(xm.getBytes("iso8859-1"), "utf-8");
        String gbb = new String(gb.getBytes("iso8859-1"), "utf-8");
        System.out.println(xmm+"\n"+gbb); 
  }
}

4、结果:

姓名
国家地区

 

posted @ 2021-09-26 21:07  娜梓  阅读(33)  评论(0编辑  收藏  举报