获得tomcat文件夹的路径
以下:
/**
* <获得文件路径>
* <功能详细描述>
* @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;
}
还没有评论,来说两句吧...