您的位置:首页 > 运维架构

Properties文件工具读取类

2015-08-28 14:41 190 查看
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;
}

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