public static String[] getItemValue(String key) {
try {
// /D:/软件/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/wtpwebapps/BIRUNET/WEB-INF/classes/
String path = new CheckItems().getClass().getResource("/").getPath() ;
// D:/软件/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/wtpwebapps/BIRUNET/WEB-INF/
String substring = path.substring(1, path.length()-8);
// D:/软件/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/wtpwebapps/BIRUNET/WEB-INF/ITEMS/items.properties
substring = substring +"ITEMS/items.properties";
File files = new File(substring);
if(!files.exists()){
throw new RuntimeException("要读取的文件不存在");
}
String[] value = null;
inputFile = new FileInputStream(files);
propertie.load(inputFile);
inputFile.close();
if (propertie.containsKey(key)) {
value = propertie.getProperty(key).split(",");
return value;
} else
return value;
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}// end getValue( )
ssm 获取WEB-INF的绝对路径
最新推荐文章于 2021-03-02 18:28:21 发布