创建删除非空目录的方法
import java.io.File; import java.io.IOException;/** 来 自 时代Java**/ public class Main { public static void main(String[] arg) throws IOException { File f = new File("myfile.txt"); deleteFile(f); } private static void deleteFile(File dir) { File[] files = dir.listFiles(); for (File f : files) { if (f.isDirectory()) deleteFile(f); else f.delete(); } dir.delete(); }/*from n o w j a v a . c o m - 时代Java*/ }