举例:
config.properties内容如下:Server=127.0.0.1
name=test要把config.properties文件放在classpath里。PropertyResourceBundle configBundle = (PropertyResourceBundle)PropertyResourceBundle.getBundle("config"); //这样调用config.properties文件
server_ip = configBundle.getString("Server"); //得到其中的一个设置
config.properties内容如下:Server=127.0.0.1
name=test要把config.properties文件放在classpath里。PropertyResourceBundle configBundle = (PropertyResourceBundle)PropertyResourceBundle.getBundle("config"); //这样调用config.properties文件
server_ip = configBundle.getString("Server"); //得到其中的一个设置
比如:
bundle.properties 缺省
bundle_zh.properties 中文
bundle_ja.properties 日文ResourceBundle bundle= ResourceBundle.getBundle("bundle");
如果你的系统是中文的,那就会自动加载bundle_zh.properties 不过多字节编码的bundle需要用native2ascii转成unicode编码。