public static void deleteDir(String dirPath){
File file = new File(dirPath);
if (file.isDirectory()) {
String[] files = file.list();
for (String f : files) {
deleteDir(f);
}
}
else {
if(file.isFile())
file.delete();
}
}
if (file.isDirectory()) {
String[] files = file.list();
for (String f : files) {
deleteDir(f);
}
file.delete();//刪除文件夾下的文件後,是空目錄,刪除空目錄