Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.File;

public class Main {
    public static void main(String[] args) {
        // Change the dirPath value to list files from your directory
        String dirPath = "C:\\";

        File dir = new File(dirPath);
        File[] list = dir.listFiles();

        for (File f : list) {
            if (f.isFile()) {
                System.out.println(f.getPath() + "  (File)");
            } else if (f.isDirectory()) {
                System.out.println(f.getPath() + "  (Directory)");
            }
        }
    }
}