JAVA_File

package com.kk.review;

import java.io.File;

public class FileTest {
    public static void main(String[] args) {
        getAllFileName(new File("F:/"));
    }
    
    /**
     * 递归获取所有文件
     * @param file
     */
    static void getAllFileName(File file){
            for(File f:file.listFiles()){
                if (f.isDirectory()) {
                    getAllFileName(f);
                }else{
                    System.out.println(file.getName());
                }
            }
    }
}

原文地址:https://www.cnblogs.com/BigIdiot/p/2281765.html