java项目部署后的文件路径获取

        //eclipse部署工程
        String path = request.getServletContext().getRealPath(
                File.separator+ "WEB-INF" + File.separator
            + "platform"+ File.separator
            +"configuration"+ File.separator
            +"services");
        //tomcat部署工程
        if(path==null){
            String tomcatBinPath = System.getProperty("user.dir");
            String tomcatRootPath = tomcatBinPath.substring(0, tomcatBinPath.lastIndexOf(File.separator));
            path = tomcatRootPath+File.separator+"webapps"+File.separator+"jointos"+File.separator+ "WEB-INF" + File.separator + "platform"+ File.separator
            +"configuration"+ File.separator+"services";
        }

以上方式可以获取到java项目部署后的路径中找到特定目录下的特定文件

你可能感兴趣的:(java项目部署后的文件路径获取)