Java Utililty Methods File Path Delete

List of utility methods to do File Path Delete

Description

The list of methods to do File Path Delete are organized into topic(s).

Method

voiddelAll(String path)
del All
File f = new File(path);
if (f.isDirectory()) {
    String[] children = f.list();
    for (String folder : children) {
        String newPath = path + "/" + folder;
        delAll(newPath);
f.delete();
voiddelAllFile(String path)
delete all files inside folder
File file = new File(path);
if (!file.exists()) {
    return;
if (!file.isDirectory()) {
    return;
if (file.getAbsolutePath().equalsIgnoreCase("/")) {
...
booleandelAllFiles(File dir, String prefix)
del All Files
boolean bUnableToDeleteSomeFiles = false;
String[] fileList = dir.list();
String path = dir.getAbsolutePath() + File.separator;
File file;
for (int i = 0; i < fileList.length; ++i) {
    if (fileList[i].startsWith(prefix)) {
        try {
            file = new File(path + fileList[i]);
...
voiddelAllFiles(File dir, String suffix)
del All Files
List files = findAllFiles(dir, suffix);
for (Iterator it = files.iterator(); it.hasNext();) {
    File file = (File) it.next();
    file.delete();
voiddelDir(String path)
del Dir
File dir = new File(path);
if (dir.exists()) {
    dir.delete();
voiddelDirAndFile(String tempath)
del Dir And File
File f = new File(tempath);
if (f.isDirectory()) {
    File[] l = f.listFiles();
    for (int i = 0; i < l.length; i++) {
        delDirAndFile(l[i].getAbsolutePath());
f.delete();
...
intdeleleFiles(String regex, String path)
delele Files
int rtn = 0;
if (path != null && regex != null) {
    File folder = new File(path);
    File[] files = folder.listFiles();
    for (int i = 0; i < files.length; i++) {
        String fname = files[i].getName();
        if (fname.matches(regex)) {
            if (files[i].delete()) {
...
voiddelEmptyPath(String path)
del Empty Path
File file = new File(path);
if (file.exists() && file.isDirectory()) {
    File[] files = file.listFiles();
    if (files != null && files.length > 0)
        return;
    if (file.delete()) {
        delEmptyPath(file.getParent());
voiddelete(File path)
delete
if (!path.delete())
    throw new RuntimeException("Could not delete " + path.getAbsolutePath());
booleandelete(File path)
Delete the whole directory
boolean res = true, tmp = true;
if (path.exists()) {
    File[] files = path.listFiles();
    for (int i = 0; i < files.length; i++) {
        if (files[i].isDirectory()) {
            tmp = delete(files[i]);
        } else {
            tmp = deleteFile(files[i]);
...