深层删除一个目录(java)
package test; import java.io.*; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; import java.util.zip.InflaterInputStream; import javax.annotation.processing.FilerException; import privateclass.Filterby_Name; import privateclass.Filterby_hidden; import privateclass.Filterby_java; import privateclass.MyBufferedReader; public class Main { private static final String space_operator = " "; private static final double pi = Math.PI; private static final String LINE_SEPARATOR = System.getProperty("line.separator"); public static void main(String[] args) throws Exception { File file = new File("d:\\5"); // deleteall(file); System.out.println(file.isDirectory()); } public static void deleteall(File file) { for(File file2 : file.listFiles()) { if(file2.isDirectory()) { deleteall(file2); } else { System.out.println(file2.getName() + file2.delete()); } } System.out.println(file.getName() + file.delete()); } }