您的位置:首页 > 编程语言 > Java开发

Java获取properties配置文件信息

2015-11-25 09:56 706 查看
调用方法:String url = PropertiesUtil.getProperty("url");

public class PropertiesUtil {

public static Properties property;
static {
property = new Properties();
InputStream in = PropertiesUtil.class.getResourceAsStream("/init.properties");
try {
property.load(in);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

public static String getProperty(String key) {
return property.getProperty(key);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: