Java Force Delete forceDelete(File file)

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

Description

force Delete

License

Apache License

Declaration

private static void forceDelete(File file) throws IOException 

Method Source Code


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

import java.io.*;

public class Main {
    private static void forceDelete(File file) throws IOException {
        if (file.isDirectory()) {
            File[] files = file.listFiles();
            for (File child : files) {
                forceDelete(child);/*w w w.j a  v  a 2 s  .  com*/
            }
            deleteFile(file);
        } else {
            deleteFile(file);
        }
    }

    public static void deleteFile(File file) throws IOException {
        if (file == null) {
            return;
        }
        if (!file.delete()) {
            throw new IOException("Unable to delete file: " + file);
        }
    }
}

Related

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