您的位置:首页 > 其它

一个读取属性文件例子

2005-06-29 10:26 337 查看
/*
*
* File: AppProperties.java
* Date: 2005-6-28
* Author: fuwl
* project: DB2Trans
* Ver:1.00
* Note:
*/
package com.toone.egov.common.util;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
/**
* @author fuwl
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class AppProperties
{
private final static String PropFile = "App.properties" ;
private static AppProperties appProp = null;
private Properties prop;
/*私有默认构造函数,保证外界无法直接实例化*/
private AppProperties() throws IOException
{
prop = new Properties();
FileInputStream fis = new FileInputStream(PropFile);
prop.load(fis);
}
synchronized public static AppProperties getInstance() throws IOException
{
if(appProp == null)
{
appProp = new AppProperties();
}
return appProp;
}
public static void main(String args[]) throws Exception
{
System.out.println("prop 1.1");
System.out.println(AppProperties.getInstance().prop.getProperty("foo"));
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐