读配置文件 properties
/**
*
*/
package com.sprucetec.tms.fee.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
* 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());
}
}
}
}
读配置文件 properties的更多相关文章
- 复习课程jdbc:使用配置文件properties进行连接数据库,数据库存取图片,批处理,时间戳,事物回滚等等
使用配置文件properties进行连接数据库 首先创建一个file自定义文件名,但是后缀名必须改为.properties(不分大小写):如config.properties: 然后双击config. ...
- java工具类-读配置文件
///读配置文件 import java.io.InputStream;import java.util.HashMap;import java.util.Map;import java.util.M ...
- 操作配置文件Properties
// */ // ]]> 操作配置文件Properties Table of Contents 1 定义 2 读取配置值 3 修改和保存配置 4 注意 1 定义 csharp中在Settin ...
- Java配置文件Properties的读取、写入与更新操作
/** * 实现对Java配置文件Properties的读取.写入与更新操作 */ package test; import java.io.BufferedInputStream; import j ...
- 【转】spring管理属性配置文件properties——使用PropertiesFactoryBean|spring管理属性配置文件properties——使用PropertyPlaceholderConfigurer
spring管理属性配置文件properties--使用PropertiesFactoryBean 对于属性配置,一般采用的是键值对的形式,如:key=value属性配置文件一般使用的是XXX.pr ...
- 对Java配置文件Properties的读取、写入与更新操作
http://breezylee.iteye.com/blog/1340868 对Java配置文件Properties的读取.写入与更新操作 博客分类: javase properties 对Jav ...
- 实现对Java配置文件Properties的读取、写入与更新操作
/** * 实现对Java配置文件Properties的读取.写入与更新操作 */ package test; import java.io.BufferedInputStream; import j ...
- 读取配置文件properties的几种方式
介绍几种读取方式:参考:https://www.cnblogs.com/sebastian-tyd/p/7895182.html .基于ClassLoder读取配置文件 注意:该方式只能读取类路径下的 ...
- 6.12-PrepareStatement,JdbcUtil 读取数据库配置文件properties,dao模式
一.PrepareStatement 防止sql注入 PrepareStatement 是预编译sql语句 更加灵活,更有效率 executeUpdate() 做增删改 executeQuery() ...
随机推荐
- action接收到来自jsp页面的请求时出现中文乱码问题处理方法
写JSP程序时,在Servlet中取请求参数时出现了乱码,当然,这种乱码问题再简单不过了.由于在JSP中使用了GBK作用页面的编码,那么提交的中文信息自然也会被按着GBK进行编码,为%xx格式的GBK ...
- Ubuntu root登陆
分两步: 1.激活root 输入命令:sudo passwd,键入当前用户密码之后,为系统设置root密码:交互如下: jack@ubuntu:~$ sudo passwd[sudo] passwor ...
- Oracle EBS-SQL (PO-11):检查采购订单退货数.sql
select msi.segment1 物料编码, -- msi.inventory_item_id return_it ...
- jQuery学习-事件之绑定事件(七)
今天来说说事件中的handlers方法中的一个片段 1 matches[ sel ] = handleObj.needsContext ? 2 jQuery( sel, this ).in ...
- rpm安装软件(需管理员权限)
常用命名规范 linux-1.2.0-30.e16.i686.rpm rpm基本命令 安装rpm -i software.rpm 卸载rpm -e software 升级rpm -U software ...
- 面向连接的socket数据处理过程以及非阻塞connect问题
对于面向连接的socket类型(SOCK_STREAM,SOCK_SEQPACKET)在读写数据之前必须建立连接,首先服务器端socket必须在一个客户端知道的地址进行监听,也就是创建socket之后 ...
- const和define的区别
1.在使用const定义常量时,只能使用标量初始化; 但我们可以使用任何表达式初始化define定义的常量 2.我们可以在条件表达式中使用define定义常量,但绝对不能使用const eg: def ...
- ORA-07445 [mdagun_iter+957] When Using SDO_AGGR_UNION 问题处理
问题描写叙述: ORA-07445: mdagun_iter() [Address not mapped to object] Oracle Database 10g Enterprise Edit ...
- 可解压带中文名称文件的zip包
package com.text.ziptest; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; i ...
- UIViewController、UINavigationController与UITabBarController的整合使用
UINavigationController与UITabBarController是iOS开发中最常用的两种视图控制器,它们都属于UIViewController的子类,继承关系如下: @interf ...