获取工程路径(兼容windows和linux)

来源:互联网 发布:linux下如何安装vim 编辑:程序博客网 时间:2024/06/03 21:18
ServletContext context = getServletContext();    String rootPath = context.getRealPath("/");    log.info("root path[" + rootPath + "]");    //如果最后一位没有分隔符,则加上    if (File.separatorChar != rootPath.charAt(rootPath.length() - 1))    {      rootPath = rootPath + File.separatorChar;    }    log.info("root path[" + rootPath + "]");    String config = getInitParameter("config");    File rootDir = new File(rootPath + "WEB-INF" + File.separatorChar);    File[] childFile = FileUtils.getFiles(rootDir, config);

0 0
原创粉丝点击