public class DelData {
public static void main(String[] agres) {
String filePath="F:\\2023_4_17_VIP\\20230120_IFS";
System.out.println("开始!");
deleteFile(filePath);
System.out.println("操作完成,请Check!");
}
public static void deleteFile(String filePath)
{
File file = new File(filePath);
String fileNmaes =file.getName();
fileNmaes=fileNmaes.toUpperCase();
if (file.isFile())
{
file.delete();
}
else
{
String[] childFilePath = file.list();//获取文件夹下所有文件相对路径
for (String path:childFilePath)
{
deleteFile(file.getAbsoluteFile()+"/"+path);//递归,对每个都进行判断
}
}
}
// public static void TOUpperFile(String filePath)
// {
//
// File file = new File(filePath);
// String fileNmaes =file.getName();
// fileNmaes=fileNmaes.toUpperCase();
// String[] childFilePath = file.list();//获取文件夹下所有文件相对路径
// for (String path:childFilePath)
// {
// File file2 = new File(path);
// String file2Name=file2.getName();
// file2Name=file2Name.toUpperCase();
// }
//
//
// }
}