ITeye博客

java获取项目物理路径

sunwch · 2010-11-10 15:12 · javase · 编程语言 · Java · Windows · Linux · Markdown


测试只在windows底下,基于Linux没测试..
private String getContextPath(){
		String contextPath = this.getClass().getResource("/").toString().replace("/", "\\\\");
		contextPath = contextPath.substring(contextPath.indexOf("\\")+2,contextPath.length());
		return contextPath;
	}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。