深层删除一个目录(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());
		
	}
    
    
}

  

posted @ 2019-11-07 23:11  WINDZLY  阅读(150)  评论(0编辑  收藏  举报