Java File Delete delete(File f)

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

Description

delete

License

Open Source License

Declaration

public static void delete(File f) throws IOException 

Method Source Code


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

import java.io.File;
import java.io.IOException;

public class Main {
    public static void delete(File f) throws IOException {
        if (f.isDirectory() && f.listFiles() != null) {
            final File[] files = f.exists() && f.listFiles() == null ? new File[0] : f.listFiles();

            assert files != null;
            for (File c : files)
                delete(c);/*w ww  .  j a  v  a  2  s .  c o  m*/
        }
        if (!f.delete()) {
            throw new IOException("Failed to delete file: " + f);
        }
    }
}

Related

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