读配置文件(properties)ConfigFileUtils
来源:互联网 发布:移动设备数据恢复 编辑:程序博客网 时间:2024/06/04 19:21
/** * */package com.sprucetec.tms.utils;import java.io.IOException;import java.util.ArrayList;import java.util.Properties;import org.apache.log4j.Logger;import org.springframework.core.io.support.PropertiesLoaderUtils;/** * * Title: ConfigFileUtils.java<br> * Description: <br> * Copyright: Copyright (c) 2016<br> * Company: 北京云杉世界信息技术有限公司<br> * * @author MiaoShun * 2016年3月2日 */public class TmsConfigFileUtils { private static final Logger logger = Logger.getLogger(TmsConfigFileUtils.class); /** * * @author meicai * 2016年3月2日 * @param nodeName * @return */ public static ArrayList<Long> getShardconfig(String nodeName) { String configName = "shard.properties"; String result = pubReadConfig(configName, nodeName); if (result == null) { result = pubReadConfig("prop/" + configName, nodeName); } String[] nodes = result.split(","); ArrayList<Long> nodeList = new ArrayList<Long>(); for(String node : nodes){ nodeList.add(Long.valueOf(node)); } return nodeList; } /** * 通用读取方法 * * @param configName * @param nodeName * @return */ public static String pubReadConfig(String configName, String nodeName) { Properties props = new Properties(); while (true) { try { props = PropertiesLoaderUtils.loadAllProperties(configName); return (String) props.get(nodeName); } catch (IOException e) { logger.error("ReadConfigException", e); System.out.println(e.getMessage()); } } }}
0 0
- 读配置文件(properties)ConfigFileUtils
- 读配置文件properties
- bat读配置文件*.properties
- 读配置文件 properties
- [Properties]——读配置文件
- Properties配置文件
- Properties配置文件
- Properties配置文件
- properties配置文件
- Properties配置文件
- properties配置文件
- Properties类读写.properties配置文件
- struts.properties配置文件详解
- struts.properties配置文件
- java 读取properties配置文件
- Java读取properties配置文件
- log4j.properties配置文件
- Log4j配置文件 log4j.properties
- Sqlserver根据某字段分隔符将一条记录拆分为多行记录
- javaGUI实现计算器的界面
- VMware11虚拟机下安装Centos6.5
- 正则表达式中\b跟\s的或运算
- ScrollView+TabLayout+ViewPager+ListView复杂滑动嵌套、上拉加载
- 读配置文件(properties)ConfigFileUtils
- 数据结构——二分法查找
- java静态方法的一个小知识点(需要注意)
- 决定创业了!雪豹计算机系统软件工作室是我迈出创业的第一步!加油!
- 获取usb设备类型
- jemalloc 3.6.0源码详解—[0]基础知识
- 自定义ViewGroup自实现笔记
- redis和cookie实现购物车
- Nginx入门简介