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.ArrayList;

import java.util.List;

public class Main {
    public static List<String> getAllFileLists(String dir) {
        List<String> results = new ArrayList<String>();

        File[] files = new File(dir).listFiles();
        //If this pathname does not denote a directory, then listFiles() returns null.

        for (File file : files) {
            if (file.isFile()) {
                results.add(file.getName());
            }
        }
        return results;
    }
}