创建文件目录

上传文件到项目webRoot下某个文件夹时,需要判断目录是否存在。

import java.io.File;
String binPath=System.getProperty("user.dir");
binPath=binPath.replace("bin", "webapps");//把bin 文件夹变到 webapps文件里面 
File temp=new File(binPath+"\ROOT\temp");
if (!temp.exists()){//如果该目录不存在则创建该文件夹
    temp.mkdir();
}
原文地址:https://www.cnblogs.com/zhutouying/p/3325649.html