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

java获取webroot下面的文件路径

2015-10-21 19:17 696 查看
/**
*
* @return WebRoot目录的绝对路径
*/
public static String getWebRootAbsolutePath() {
String path = null;
String folderPath = Path.class.getProtectionDomain().getCodeSource()
.getLocation().getPath();
if (folderPath.indexOf("WEB-INF") > 0) {
path = folderPath.substring(0, folderPath
.indexOf("WEB-INF/classes"));
}
return path;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  path