Java File Delete delete(File file)

Here you can find the source of delete(File file)

Description

delete

License

Apache License

Declaration

public static void delete(File file) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

public class Main {
    public static void delete(String path) {
        if (null == path || (path = path.trim()).isEmpty())
            throw new IllegalArgumentException("Illegal 'path' argument in Utils.delete(String): " + path);
        delete(new File(path));
    }/*from  w  w  w .  j  av  a2 s  .  co  m*/

    public static void delete(File file) {
        if (null == file)
            throw new IllegalArgumentException("Illegal 'file' argument in Utils.delete(File): " + file);
        if (file.exists()) {
            if (file.isDirectory()) {
                for (File child : file.listFiles()) {
                    delete(child);
                }
            }
            file.delete();
        }
    }
}

Related

  1. delete(File file)
  2. delete(File file)
  3. delete(File file)
  4. delete(File file)
  5. delete(File file)
  6. delete(File file)
  7. delete(File file)
  8. delete(File file)
  9. delete(File file)