Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.File;

import java.util.List;

public class Main {
    public static void deleteFiles(List<File> selectedFiles) {
        if (selectedFiles != null & selectedFiles.size() > 0) {
            for (File file : selectedFiles) {
                if (file.isFile()) {
                    file.delete();
                } else {
                    deleteDir(file);
                    //               file.delete();
                }
            }
        }
    }

    private static void deleteDir(File dir) {
        File[] files = dir.listFiles();
        if (files != null & files.length > 0) {
            for (File file : files) {
                if (file.isFile()) {
                    file.delete();
                } else if (file.isDirectory()) {
                    deleteDir(file);
                }
            }
        }
        dir.delete();
    }
}