java Properties工具
来源:互联网 发布:linux数据库备份软件 编辑:程序博客网 时间:2024/06/17 03:34
import java.util.Enumeration;
import java.util.ResourceBundle;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PropertiesUtil {
private static final Logger log = LoggerFactory.getLogger(PropertiesUtil.class);
public static ConcurrentMap< String, String > appExceptionMessageMap = new ConcurrentHashMap< String, String >();
public static ConcurrentMap<String,String> responseMessageMap = new ConcurrentHashMap<String, String>();
public static ConcurrentMap<String,String> interfaceAuthorityMap = new ConcurrentHashMap<String, String>();
public static ConcurrentMap<String,String> configMap = new ConcurrentHashMap<String, String>();
static {
init();
}
private static void init(){
try{
ResourceBundle exceptionMessage = ResourceBundle.getBundle("props/error-message");
ResourceBundle responseMessage = ResourceBundle.getBundle("props/response-message");
ResourceBundle interfaceAuthority = ResourceBundle.getBundle("props/interface-authority");
ResourceBundle config = ResourceBundle.getBundle("props/config");
initConfig(exceptionMessage,appExceptionMessageMap);
initConfig(responseMessage,responseMessageMap);
initConfig(interfaceAuthority,interfaceAuthorityMap);
initConfig(config, configMap);
} catch (Throwable t){
log.error("cofig init error .............",t);
}
}
private static void initConfig(ResourceBundle resourceBundle,ConcurrentMap map){
Enumeration< String > e = resourceBundle.getKeys();
while( e.hasMoreElements() ) {
String key = e.nextElement();
map.put( key, resourceBundle.getString( key ) != null ? resourceBundle.getString( key )
.trim() : null );
}
}
}
import java.util.ResourceBundle;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PropertiesUtil {
private static final Logger log = LoggerFactory.getLogger(PropertiesUtil.class);
public static ConcurrentMap< String, String > appExceptionMessageMap = new ConcurrentHashMap< String, String >();
public static ConcurrentMap<String,String> responseMessageMap = new ConcurrentHashMap<String, String>();
public static ConcurrentMap<String,String> interfaceAuthorityMap = new ConcurrentHashMap<String, String>();
public static ConcurrentMap<String,String> configMap = new ConcurrentHashMap<String, String>();
static {
init();
}
private static void init(){
try{
ResourceBundle exceptionMessage = ResourceBundle.getBundle("props/error-message");
ResourceBundle responseMessage = ResourceBundle.getBundle("props/response-message");
ResourceBundle interfaceAuthority = ResourceBundle.getBundle("props/interface-authority");
ResourceBundle config = ResourceBundle.getBundle("props/config");
initConfig(exceptionMessage,appExceptionMessageMap);
initConfig(responseMessage,responseMessageMap);
initConfig(interfaceAuthority,interfaceAuthorityMap);
initConfig(config, configMap);
} catch (Throwable t){
log.error("cofig init error .............",t);
}
}
private static void initConfig(ResourceBundle resourceBundle,ConcurrentMap map){
Enumeration< String > e = resourceBundle.getKeys();
while( e.hasMoreElements() ) {
String key = e.nextElement();
map.put( key, resourceBundle.getString( key ) != null ? resourceBundle.getString( key )
.trim() : null );
}
}
}
0 0
- JAVA Properties工具类
- JAVA Properties工具类
- java Properties工具
- java.util.Properties工具类
- Java Properties工具类详解
- java加载properties工具类
- java properties 的工具类
- java.util.properties工具类操作properties配置文件
- Java native2ascii工具 properties文件编码转换
- 【java工具类】properties文件操作
- Java native2ascii工具 properties文件编码转换
- java 解析properties文件 工具类 通用
- java读取Properties文件的工具类
- java【工具类】读取,修改Properties
- JAVA-Properties类和Collections工具类
- Java工具类--读取Properties文件
- 【java】获取properties配置文件信息工具类
- Java读取Properties文件工具类
- vmhgfs-bdi-kernel-4.0-tools-9.9.2.patch
- Android Camera 视频循环录制
- 学习JVM
- Codeforces Round #305 (Div. 2)--A. Mike and Fax
- [前端] jquery不常用方法测试
- java Properties工具
- linux模拟网络状况
- vimrc
- GCC 命令行详解 -L 指定库的路径 -l 指定需连接的库名
- hdu 1058 Humble Numbers【dp】
- Cppcheck
- 网易邮箱账号OAuth2.0认证文档
- java随笔
- 解析GRE数学中重要符号的英文表达