public static boolean deleteFolder(String delDir) { File delFolder = new File(delDir); File[] delFile = delFolder.listFiles(); try { for (File file : delFile) { if (file.isDirectory()) { deleteFolder(file.getPath()); } file.delete(); } } catch (Exception e) { System.out.println("清空文件夹操作出错!"); e.printStackTrace(); return false; } System.out.println("清空文件夹操作成功!"); return true; }