📄 propertymanager.java
字号:
package com.xdf.supermarket.util;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* @author hdyu
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class PropertyManager {
private static final String CONFIG = "config";
private static final ResourceBundle RESOURCE_BUNDLE =
ResourceBundle.getBundle(CONFIG);
/**
* 读取默认的config.properties文件
* @param key
* @return value
*/
public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
throw new RuntimeException( "! config : "+ key + '!');
}
}
/**
* 读取指定为rb.properties文件
* @param rb property 文件,文件名为 rb.properties
* @param key
* @return value
*/
public static String getRB(String rb, String key) throws Exception{
try {
return ResourceBundle.getBundle(rb).getString(key);
} catch (MissingResourceException e) {
throw new RuntimeException( '!' + rb + ":" + key + '!');
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -