输出某个文件夹下面的所有文件名 后缀 及路径(linux)

来源:互联网 发布:mac音频播放器 编辑:程序博客网 时间:2024/06/05 04:50

import java.io.File;

public class GetFoldFileNames {

/** * * @author zdz8207 */public static void main(String[] args) {    String path= "/"; // 路径    File f = new File(path);    getFileName(f);}public static void getFileName(File f) {    //String path= "/home/cnking"; // 路径    //File f = new File(path);    if (!f.exists()) {        System.out.println(" not exists");        return;    }    File fa[] = f.listFiles();    for (int i = 0; i < fa.length; i++) {        File fs = fa[i];        if (fs.isDirectory()) {            // File[] t =  fs.listFiles();            getFileName(fs);            System.out.println(fs.getName() + " [目录]");        } else {            System.out.println(fs.getName());        }    }}

}

阅读全文
1 0
原创粉丝点击