java获取项目物理路径

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

你可能感兴趣的:(java,windows,linux)