Java File Path Delete deleteFiles(String filePath)

Here you can find the source of deleteFiles(String filePath)

Description

delete Files

License

Open Source License

Declaration

public static boolean deleteFiles(String filePath) 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 boolean deleteFiles(String filePath) throws IOException {
        File f = new File(filePath);
        if (!f.exists()) {
            return true;
        }//from   ww w .  j  a v  a 2 s .c  o  m

        if (f.isDirectory()) {
            File[] files = f.listFiles();
            if (files != null) {
                for (int i = 0, len = files.length; i < len; i++) {
                    if (files[i].isFile()) {
                        files[i].delete();
                    } else {
                        deleteFiles(files[i].getAbsolutePath());
                    }
                }
            }
        }
        return f.delete();
    }
}

Related

  1. deleteFileIfExists(String path)
  2. deleteFileOrDirectory(String path)
  3. deleteFileOrDirectory(String path)
  4. deleteFiles(final File pathname)
  5. deleteFiles(String actionPath, String filePath)
  6. deleteFilesInDirectory(File path)
  7. deleteFilesInDirectory(String pathname)
  8. deleteFilesinPath(File pBaseDir, String pFileName)
  9. deleteFilesRecursive(final File path)