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");
}
}
本文介绍了一个Java类,该类用于从指定的路径加载属性文件并读取特定的属性值。通过使用类路径和文件系统的组合路径,实现了对内容根名称的获取。

被折叠的 条评论
为什么被折叠?



