码迷,mamicode.com
首页 > 其他好文 > 详细

Properties文件工具读取类

时间:2015-08-28 15:23:19      阅读:111      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!