java.util.Properties读取properties文件
2016-01-21 10:16
441 查看
Properties prop = new Properties();
InputStream inStream = null;
try
{
//具体路径
inStream = new FileInputStream("......//typeMap.properties");
prop.load(inStream);
Enumeration<String> e = (Enumeration<String>)prop.propertyNames();
String key = null;
String value = null;
String[] values = null;
boolean hasMoreElements = e.hasMoreElements();
while (hasMoreElements)
{
key = (String)e.nextElement();
value = prop.getProperty(key);
hasMoreElements = e.hasMoreElements();
}
}
catch (FileNotFoundException e1)
{
//todo
}
catch (IOException e1)
{
//todo
}
finally
{
try
{
if (null != inStream)
{
inStream.close();
}
}
catch (IOException e1)
{
//todo
}
}
InputStream inStream = null;
try
{
//具体路径
inStream = new FileInputStream("......//typeMap.properties");
prop.load(inStream);
Enumeration<String> e = (Enumeration<String>)prop.propertyNames();
String key = null;
String value = null;
String[] values = null;
boolean hasMoreElements = e.hasMoreElements();
while (hasMoreElements)
{
key = (String)e.nextElement();
value = prop.getProperty(key);
hasMoreElements = e.hasMoreElements();
}
}
catch (FileNotFoundException e1)
{
//todo
}
catch (IOException e1)
{
//todo
}
finally
{
try
{
if (null != inStream)
{
inStream.close();
}
}
catch (IOException e1)
{
//todo
}
}
相关文章推荐
- 使用Arrays类操作Java中的数组
- Java堆
- Java7中的switch支持String的实现细节
- maven+spring+springmvc+hibernate+easyui的真实项目经历
- java中判断字符串是否为数字的三种方法
- Java算法分析与设计视频教程
- java集合总结
- 内存溢出和内存泄露的区别
- 如何在Java平台上使用脚本语言做Java开发
- Java取整函数 四舍五入函数
- Quartz在Spring中的集群
- Quartz在Spring中的集群
- Java方法栈区抛出的异常
- java自带线程池和队列详细讲解
- JAVA跑马灯实现1
- java反射机制简介
- Learning Java(1)——安装&HelloWorld
- 深入理解Java内存模型(一)——基础
- Java中一些基本概念详解:栈、堆、对象大小、引用、传值(转)
- Java EE标准体系概述