java使用Properties类生成配置文件
2013-07-08 11:03
344 查看
1、生成 .xml 格式的配置文件:
1.1 生成配置文件
Properties properties = new Properties();//生成实例
properties.setProperty("qq", "com.tarena.factory.QQ");//设置键值 key----value
properties.storeToXML(new FileOutputStream("tarena.xml"), "k---v");//像新文件存储
1.2 加载配置文件
Properties properties2 = new Properties();
properties2.loadFromXML(new FileInputStream("tarena.xml"));
2、生成 .properties 格式的配置文件:
2.1 生成配置文件
Properties properties = new Properties();//生成实例
properties.setProperty("qq", "com.tarena.factory.QQ");//设置键值 key----value
properties.store(new FileOutputStream("tarena.properties"), "key===value");
2.2 加载配置文件
Properties properties2 = new Properties();
roperties2.load(new FileInputStream("tarena.properties"));
1.1 生成配置文件
Properties properties = new Properties();//生成实例
properties.setProperty("qq", "com.tarena.factory.QQ");//设置键值 key----value
properties.storeToXML(new FileOutputStream("tarena.xml"), "k---v");//像新文件存储
1.2 加载配置文件
Properties properties2 = new Properties();
properties2.loadFromXML(new FileInputStream("tarena.xml"));
2、生成 .properties 格式的配置文件:
2.1 生成配置文件
Properties properties = new Properties();//生成实例
properties.setProperty("qq", "com.tarena.factory.QQ");//设置键值 key----value
properties.store(new FileOutputStream("tarena.properties"), "key===value");
2.2 加载配置文件
Properties properties2 = new Properties();
roperties2.load(new FileInputStream("tarena.properties"));
相关文章推荐
- IT咨询顾问:一次吐血的项目救火 java或判断优化小技巧 asp.net core Session的测试使用心得 【.NET架构】BIM软件架构02:Web管控平台后台架构 NetCore入门篇:(十一)NetCore项目读取配置文件appsettings.json 使用LINQ生成Where的SQL语句 js_jquery_创建cookie有效期问题_时区问题
- 使用hibernate扩展工具Hbm2JavaTask根据配置文件生成持久化对象类(2.1.2)
- protobuf的配置原始文件.proto中,使用修饰符repeated、required、optional生成的java文件的区别
- 使用java.util.Properties类读写配置文件
- 【JAVA】使用Eclipse依赖生成jar包时,避免最外层同时生成资源文件的配置。
- Java读写配置文件——Properties类的简要使用笔记
- 【深入JAVA】Java中使用配置文件——properties类
- 使用java.util.Properties类读写配置文件
- Java使用Properties类读取配置文件
- java使用Properties类读取配置文件信息
- [Java学习]使用digester 解析xml配置文件
- 使用hibernate自动生成实体类时同时出现两个.java文件
- 使用Java读取配置文件
- [JAVA][Structs]Structs使用多个配置文件
- java使用FileSystem上传文件到hadoop分布式文件系统配置
- Java使用DOM生成XML文件
- 【Java编程】写入、读取、遍历配置文件 Properties类
- 使用myeclipse从数据库反射生成hibernate实体类和配置文件
- android使用ant自动打包(更改java文件中的属性值,批量自动生成)
- JavaHost:使用虚拟DNS省掉开发环境配置hosts文件