Java Force Delete forceDelete(final File file)

Here you can find the source of forceDelete(final File file)

Description

force Delete

License

Apache License

Declaration

public static void forceDelete(final File file) 

Method Source Code


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

import java.io.File;

public class Main {
    public static void forceDelete(final File file) {
        if (file.exists()) {
            if (file.isDirectory()) {
                for (final File f : file.listFiles()) {
                    forceDelete(f);//ww w.  j a  v  a  2  s.  c om
                }
            }

            try {
                if (!file.delete()) {
                    file.deleteOnExit();
                }
            } catch (final Exception e) {
            }
        }
    }
}

Related

  1. forceDelete(File file)
  2. forceDelete(File file)
  3. forceDelete(File file)
  4. forceDelete(File file)
  5. forceDelete(File path)
  6. forceDelete(final File file)