properties操作。
来源:互联网 发布:互联网公平台用java 编辑:程序博客网 时间:2024/06/06 11:04
1.读取properties
假设properties文件在项目跟目录/classes/path.properties
String rootPath=this.getClass().getClassLoader().getResource("/").getPath()+"path.properties";
Properties pps = new Properties();InputStream in = new BufferedInputStream(new FileInputStream(rootPath));pps.load(in);
2.遍历
/** * */package pkg;import java.util.Enumeration;import java.util.Iterator;import java.util.Map.Entry;import java.util.Properties;/** * @author qefee * */public class ShowProperties {/** * @param args */public static void main(String[] args) {Properties properties = System.getProperties();// show keysshowKeys(properties);// show valuesshowValues(properties);// show keys and valuesshowKeysAndValues(properties);}/** * @param properties */private static void showKeys(Properties properties) {Enumeration<?> enu = properties.propertyNames();while (enu.hasMoreElements()) {Object key = enu.nextElement();System.out.println(key);}}/** * @param properties */private static void showValues(Properties properties) {Enumeration<Object> enu = properties.elements();while (enu.hasMoreElements()) {Object value = enu.nextElement();System.out.println(value);}}/** * @param properties */private static void showKeysAndValues(Properties properties) {Iterator<Entry<Object, Object>> it = properties.entrySet().iterator();while (it.hasNext()) {Entry<Object, Object> entry = it.next();Object key = entry.getKey();Object value = entry.getValue();System.out.println("key :" + key);System.out.println("value :" + value);System.out.println("---------------");}}}
0 0
- properties操作。
- java properties 操作-
- 操作properties文件
- java操作properties文件
- Java操作properties文件
- properties文件操作心得
- Properties操作例子类
- Java操作Properties文件
- properties文件操作类
- JAVA操作properties文件
- JAVA操作properties文件
- JAVA操作properties文件
- JAVA操作properties文件
- Properties文件操作
- JAVA操作properties文件
- JAVA操作properties文件
- properties配置文件操作实例
- JAVA操作properties文件
- CoreAnimation编程指南(六)动画
- C#笔记 垃圾回收garbage collection
- ROS学习手记12 -- ROS问题检测工具roswtf
- Activity Intent Flags及Task相关属性
- 我的书单和简单书评(持续更新)
- properties操作。
- Unity3D研究之与根据动态的两个轨迹点绘制面详解
- 当大数据遇见应用性能管理(概念篇①)
- CoreAnimation编程指南(七)图层Action
- Spring-Controller单元测试
- 通过js、jquery、ajax将php的输出传给html元素
- BIRT --百度百科
- Android SQLite数据库增删改查操作的使用详解
- 高并发解决方案