存在则删除
不存在则创建
public void isFilePath(String folderPath) { //folderPath 本地目录路径
// 将URL路径转换为File对象 保证创建一个新文件
File folder = new File(folderPath);
// 判断目录是否存在
if (folder.exists()) {
// 存在则删除
deleteDirectory(folder);
}
// 创建目录
if (folder.mkdirs()) {
System.out.println("Directory created successfully");
} else {
System.out.println("Failed to create directory");
}
}
1603

被折叠的 条评论
为什么被折叠?



