创建文件目录

上传文件到项目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();
}

 

posted @ 2013-09-17 09:39  爱笑的狐狸  阅读(151)  评论(0编辑  收藏  举报