class读取properties方式
来源:互联网 发布:帝国cms手机站教程 编辑:程序博客网 时间:2024/05/22 01:34
class读取properties方式
1)
String p1 = Thread.currentThread().getContextClassLoader().getResource("").getPath()+"\\database.properties";
Properties p2 = new Properties();
FileReader fr = new FileReader(new File(p1));
p2.load(fr);
2)
Properties pro = new Properties();//database.properties
InputStream in = this.getClass().getClassLoader() .getResourceAsStream("database.properties");//默认是classpath范围的资源
pro.load(in);
3.通过apache的commons-configuration组件
Configuration config = new PropertiesConfiguration("database.properties");
config.setReloadingStrategy(new FileChangedReloadingStrategy()); //使用自动加载
config.setProperty("colors.background", "#000000); config.save();
config.setAutoSave(true); //设置属性后自动保存
colors.pie = #FF0000, #00FF00, #0000FF另外一种作法, 你可以通过多行的同名键值对,来返回一组值。String[] colors = config.getStringArray("colors.pie"); //你不用手动拆分字符串,可以直接作为数组返回:
colors.pie = #FF0000; colors.pie = #00FF00; colors.pie = #0000FF;
- class读取properties方式
- Properties 文件读取方式
- Spring读取properties方式
- properties文件的读取方式
- 读取properties文件的方式
- 实现编码方式读取properties
- properties文件读取的几种方式
- 读取Properties的六种方式
- Properties 文件 读取 的几种方式
- Spring使用程序方式读取properties文件
- Spring使用程序方式读取properties文件
- Java 读取属性文件Properties,方式2
- spring+junit4+注解方式PropertiesFactoryBean读取properties
- spring注解方式读取properties文件中值
- java读取properties 的最简单方式
- Spring 读取properties文件key+value方式
- 读取配置文件properties的简单方式
- 读取.properties文件的两种方式
- C程序设计语言 作业1-12
- CSS单位
- mysql -u root -p 等这些常用的参数
- vs2012 编译boost库 兼容xp系统
- wpf 音乐盒 歌搜索下载功能实现
- class读取properties方式
- c#基础加强2
- 使用Pull解析器生成和解析XML文件
- 关于oracle with as用法
- 回调函数--以ZSTACK为例
- Oracle DBA常用查询
- sqllite limit offset 分页查询
- 二次探测再散列散列表 源代码(数据结构)
- ubuntu 12.04 source.list bak