读取properties文件并遍历输出
2016-07-11 00:00
393 查看
读取properties文件,生成map,并遍历输出所有的key--value
package com; import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.Map.Entry; public class ReadProperties { private static Map<Object, Object> contains = new HashMap<Object, Object>(); private static Properties p = null; public static void main(String[] args) { InputStream in = null; try { in = new BufferedInputStream(new FileInputStream("w:/printContract.properties")); p = new Properties(); p.load(in); contains = p; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } int i = 1; for (Entry<Object, Object> item : contains.entrySet()) { System.out.println("第"+i+"个key是:"+item.getKey()); System.out.println("第"+i+"个value是:"+item.getValue());; i++; } } }
相关文章推荐
- docker镜像
- 在eclipse中修改tomcat端口
- Hadoop单机安装详细步骤
- No operations allowed after statement closed.
- COPY
- 不小心一个命令触及到了Docker的底限了,他爆发了
- Nginx 502的问题
- Nginx修改端口号
- nginx同一iP多域名配置方法
- nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Ad
- docker : etcd +flannel 多机互联
- 分享一个CQRS/ES架构中基于写文件的EventStore的设计思路
- docker 镜像生成
- Snapshot Volume 操作 - 每天5分钟玩转 OpenStack(58)
- 一个简单的AXIS远程调用Web Service示例
- Pycharm对openstack进行远程调试
- operator new之non-member operator new固守规则
- 图解微服务架构演进
- Java应用架构的演化之路
- Linux入门---创建新用户