读取属性文件
1、读取webroot下面的web-inf 下面属性文件
?
package com.bitbao.cm.common.utils;import java.io.IOException;import java.io.InputStream;import java.util.Properties;import org.apache.log4j.Logger;/** * 功能描述:该类负责读取fileupload.properties文件内容 * 创建时间:2010-12-06 * @author 徐士刚 * @version 1.0.0 */public class CommonReaderProperty extends Properties{private static final long serialVersionUID = 1L;private final Logger logger = Logger.getLogger(this.getClass());private static CommonReaderProperty readerProperty;/** * 创建当前类的实例 * @return */public static CommonReaderProperty getReaderProperty(){if(readerProperty==null){makeInstance();}return readerProperty;}private static synchronized void makeInstance(){if(readerProperty==null){readerProperty = new CommonReaderProperty();}}/** * 加载资源文件 */private CommonReaderProperty(){InputStream is = this.getClass().getResourceAsStream("/fileupload.properties");try {load(is);} catch (IOException e) {logger.info("加载jdbc.properties文件时异常!异常发生在com.future.util.CommonReaderProperty类的私有构造方法,异常信息:"+e.getMessage(),e.fillInStackTrace());}}}
?