Java File Delete delete(File file)

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

Description

delete

License

Open Source License

Declaration

public static void delete(File file) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {
    public static void delete(File file) throws IOException {
        if (file.isDirectory()) {
            File[] files = file.listFiles();
            if (files != null) {
                for (File each : files) {
                    delete(each);/*from  www  . j  av  a2 s .  c om*/
                }
            }
        }
        for (int i = 0; i < 10; i++) {
            if (file.delete() || !file.exists())
                return;
            try {
                Thread.sleep(10);
            } catch (InterruptedException ignore) {
            }
        }
        if (file.exists())
            throw new IOException("Cannot delete file " + file);
    }
}

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)