获取src下文件路径(本地+服务器)
2017-04-18 10:25
337 查看
//获取src下文件所在本地路径
public static String getFilePath2(String _fileName) {
File directory = new File("");// 参数为空
String _filePath = null;
try {
_filePath = directory.getCanonicalPath();
} catch (IOException e) {
e.printStackTrace();
}
return _filePath + "\\src\\" + _fileName;
}
//获取src下文下所在服务器路径
public static String getFilePath(String _fileName) {
// String
// _filePath=request.getSession().getServletContext().getRealPath("/");
// String _url= _filePath+"WEB-INF//classes//"+"123789.pfx";
String url = new ShanghaiYHUtil().getClass().getClassLoader().getResource("/").toString();
url = (url.substring(5, url.length()) + _fileName);
logger.info("********************************" + url);
return url;
}
public static String getFilePath2(String _fileName) {
File directory = new File("");// 参数为空
String _filePath = null;
try {
_filePath = directory.getCanonicalPath();
} catch (IOException e) {
e.printStackTrace();
}
return _filePath + "\\src\\" + _fileName;
}
//获取src下文下所在服务器路径
public static String getFilePath(String _fileName) {
// String
// _filePath=request.getSession().getServletContext().getRealPath("/");
// String _url= _filePath+"WEB-INF//classes//"+"123789.pfx";
String url = new ShanghaiYHUtil().getClass().getClassLoader().getResource("/").toString();
url = (url.substring(5, url.length()) + _fileName);
logger.info("********************************" + url);
return url;
}
相关文章推荐
- 获取项目文件在服务器的真实路径
- JavaScript 获取上传文件的本地绝对路径
- PHP获取当期前运行文件的路径,名字,服务器路径
- servlet中获取各种相对地址(服务器、服务器所在本地磁盘、src等)。
- asp获取当前文件在服务器上的全路径收藏
- Atitit. 软件GUI按钮与仪表盘--web服务器区--获取apache配置文件路径 linux and apache的启动、停止、重启
- c# 获取服务器文件的路径
- Flex调用js获取本地所选文件的路径
- PHP获取当期前运行文件的路径,名字,服务器路径
- 获取项目文件在服务器的真实路径
- IE8上传文件时获取文件本地路径问题(C:\fakepath\……)的解决办法
- IE8上传文件时获取文件本地路径问题(C:\fakepath\……)的解决办法
- 获取服务器文件路径(并向TXT写入数据代码)
- asp获取当前文件在服务器上的全路径
- C# Winform 上传本地文件到服务器路径
- 使用VBS通过3种方式浏览本地文件,获取完整路径。
- IE8上传文件时获取文件本地路径问题(C:\fakepath\……)的解决办法
- springMVC 获取本地项目路径 以及上传文件的方法整理
- winform WebBrowser 文件下载拦截 获取文件本地保存路径
- js/jquery 获取本地文件的文件路劲 获取input框中type=‘file’ 中的文件路径