FILE 创建

public class CreateDelFileUtils implements Serializable{

/**
*
*/
private static final long serialVersionUID = 6901439536149050733L;
private CreateDelFileUtils(){}

/**
* 通过传入的当前用户,清空当前用户所在的个人excel文件生成文件夹.
* @param employee 当前登录用户
*/
public static String delAndCreateSessionUser(String userId , String userName) {
if (userId == null || userId.trim().length() < 1) {
return null;
}

String path = CreateDelFileUtils.class.getResource("/").getPath();
path = path.substring(0,path.indexOf("WEB-INF"));
//path = "e:/";
File file = new File(path + "chart-image/" + userId);
if (file.exists()) {
file.delete();
}

file.mkdir();
return path + "chart-image/" + userId;
}

public static void main(String[] args) {
delAndCreateSessionUser("zhao","123");
}

}

原文地址:https://www.cnblogs.com/lovezhaolei/p/3251094.html