获得tomcat文件夹的路径

来源:互联网 发布:java ftp下载文件夹 编辑:程序博客网 时间:2024/06/11 00:43

以下:

/**     * <获得文件路径>     * <功能详细描述>     * @return     * @see [类、类#方法、类#成员]     */    public String getPath()    {        //当前盘符路径,会获得tomcat/bin文件夹所在的路径        File file = new File("");        String path = file.getAbsolutePath().replaceAll("\\\\", "/");        int mark = path.lastIndexOf("/");        //修改路径,获得tomcat/webapps/data文件夹路径        String newPath = path.substring(0, mark) + "/webapps/data";        File f = new File(newPath);        if (!f.exists())        {            f.mkdir();        }        return newPath;    }


1 0