使用ResourceBundle国际化资源文件读取properties详解

来源:互联网 发布:显示器接网络机顶盒 编辑:程序博客网 时间:2024/05/17 03:51
eg:public  class Commons {    //工具类创建常量    public static String EMAIL_ACCOUNT;    public static String EMAIL_PASSWORD;    //静态区域块读取 properties     static{        ResourceBundle resource=ResourceBundle.getBundle("init");        EMAIL_ACCOUNT=resource.getString("email_account").trim();        EMAIL_PASSWORD=resource.getString("email_password").trim();    }       
//创建的   properties 配置email_account=ygc@qq.comemail_password=ygc123456
//在程序里可以通过类+常量名直接调用定义在properties 的配置信息    Commons.EMAIL_ACCOUNT;    Commons.EMAIL_PASSWORD
阅读全文
0 0
原创粉丝点击