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

java 读取properties配置文件

2008-08-08 16:37 741 查看
public class Content(){

private String getContentRootName()
{
String fileName =Content.class.getResource("/").getPath()
+ "template/content.properties";
fileName = fileName.substring(1);
Properties prop = new Properties();
try {
InputStream is = new BufferedInputStream(new FileInputStream(fileName));
prop.load(is);
if (is != null)
is.close();
} catch (Exception e) {
System.out.println(e + "file " + fileName + " not found");
}
return prop.getProperty("contentRoorName");
}

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