Java Delete File or Directory deleteFileOrDir(File dir, int max)

Here you can find the source of deleteFileOrDir(File dir, int max)

Description

delete File Or Dir

License

Open Source License

Declaration

static void deleteFileOrDir(File dir, int max) 

Method Source Code


//package com.java2s;
import java.io.File;

public class Main {
    static void deleteFileOrDir(File dir, int max) {
        File[] listFiles = dir.listFiles();
        if (listFiles != null && max > 0) {
            for (File file : listFiles) {
                deleteFileOrDir(file, max - 1);
            }/*w  w w . j a  v a  2 s .com*/
        }
        dir.delete();
    }
}

Related

  1. deleteFileOrDir(File fd)
  2. deleteFileOrDir(File file)
  3. deleteFileOrDir(File file)
  4. deleteFileOrDir(File filehandle)