
import java.io.File;

/**
 * Folder lister
 * @author Ageenko
 * @version 2 (Mar 18, 2003)
 */
public class FolderLister {
    private File path;

    /** Constructor.
     *
     * @param path String path to list folders in
     */
    public FolderLister(String path) {
        this.path = new File(path);
    }

    /** List folders in the current path */
    public void listFolders() {
        if (path.exists()) {
            File[] list = path.listFiles();
            for (int k = 0; k < list.length; k++) {
                File file = list[k];
                if (file.isDirectory())
                    System.out.println(file.getName());
            }
        } else {
            System.out.println("Invalid folder path");
        }
    }

    /**
     * Main Method
     * @param args <br>1: path to list folders (optional, "." by default)
     */
    public static void main(String[] args) {
        String path = (args.length > 0) ? args[0] : ".";
        FolderLister app = new FolderLister(path);
        app.listFolders();
    }
}

