Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.File;
import java.util.HashSet;
import java.util.Set;

public class Main {
    public static void main(String[] argv) {
        Set<File> all = new HashSet<File>();
        getAllFileAndFolder(new File("c:\\"), all);
    }

    public static void getAllFileAndFolder(File folder, Set<File> all) {
        all.add(folder);
        if (folder.isFile()) {
            return;
        }
        for (File file : folder.listFiles()) {
            all.add(file);
            if (file.isDirectory()) {
                getAllFileAndFolder(file, all);
            }
        }
    }
}