首页 > 其他 > 详细

Properties文件工具读取类

时间:2015-08-28 15:21:15      阅读:198      评论:0      收藏:0      [点我收藏+]

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class CommonPropertiesUtil {
    
    private static CommonPropertiesUtil instance;
    
    private CommonPropertiesUtil(){
        
    }
    
    public static synchronized CommonPropertiesUtil getInstance(){
        if(instance == null){
            instance = new CommonPropertiesUtil();
        }
        return instance;
    }

    /**
     * 读取配置文件
     * @return
     */
    public Properties loadUploadProperty() {
        Properties prop=new Properties();
        InputStream is = null;
        try {
            is = this.getClass().getResourceAsStream("/uploadConfig.properties");
            prop.load(is);
            is.close();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {  
            if (is != null) {  
                try {  
                    is.close();  
                } catch (IOException ex) {  
                    ex.printStackTrace();
                }  
            }  
        }
        return prop;
    }
    


}

Properties文件工具读取类

原文:http://www.cnblogs.com/huadoumi/p/4766513.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!