Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import java.io.File;

public class Main {
    public static boolean deleteFolder(File folder) {
        if (!folder.exists()) {
            return true;
        }

        File[] subFiles = folder.listFiles();
        if (subFiles != null) {
            for (File f : subFiles) {
                if (f.isFile()) {
                    if (!f.delete()) {
                        return false;
                    }
                } else {
                    if (!deleteFolder(f)) {
                        return false;
                    }
                }
            }
        }

        return folder.delete();

    }
}