zoukankan      html  css  js  c++  java
  • Java中通过递归调用删除文件夹下所有文件

    摘自 : http://blog.sina.com.cn/s/blog_79333b2c0100xiu4.html

    import java.io.File;

    public class FileTest
    {
     //递归删除指定路径下的所有文件
     public static void deleteAll(File file)
     {
      if(file.isFile() || file.list().length == 0)
      {
       file.delete();
      }
      else
      {
       File[] files = file.listFiles();
       for(File f : files)
       {
        deleteAll(f);//递归删除每一个文件
        f.delete();//删除该文件夹
       }
       }
     }

     

    public static void main(String[] args)
     {
      File file = new File("d:/abc/xyz");
      deleteAll(file);
     }
    }

  • 相关阅读:
    Python
    Python
    Python
    Python
    Python
    Python
    Python
    python
    对象
    py常用模块
  • 原文地址:https://www.cnblogs.com/ftm-datablogs/p/5482118.html
Copyright © 2011-2022 走看看