2008-03-24
获取工程路径(jar和普通文件结构通用) -- java
关键字: jar 路径 工程路径
/**
* 获取工程所在目录
* @return
* @throws UnsupportedEncodingException
*/
private static String getProjectPath() throws UnsupportedEncodingException{
URL url = [ThisClass].class.getProtectionDomain().getCodeSource().getLocation();
String filePath = URLDecoder.decode(url.getPath(), "UTF-8");
if(filePath.endsWith(".jar"))
filePath = filePath.substring(0, filePath.lastIndexOf("/") + 1);
return filePath;
}







评论排行榜