zoukankan      html  css  js  c++  java
  • 列出文件夹下所有文件FileUtils.listFiles

    public static void main(String[] args) {
            File dir = new File("D:\");
    //        List<File> fileList = (List<File>)FileUtils.listFiles(dir,new String[]{"doc"},true);//列出该目录下的所有doc文件,递归(扩展名不必带.doc)
    //        List<File> fileList = (List<File>)FileUtils.listFiles(dir,null,true);//列出该目录下的所有文件,递归
            List<File> fileList = (List<File>)FileUtils.listFiles(dir,null,false);//列出该目录下的所有文件,不递归
            fileList.stream().forEach(file -> System.out.println(file.getAbsolutePath()));
            //以上只输出文件路径,不输出文件夹路径,也不输出空文件夹路径
        }
    

      

    <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.6</version>
    </dependency>
    

      

    https://github.com/godmaybelieve
  • 相关阅读:
    Tensorflow实战系列之三:
    Tensorflow实战系列之二:
    scala映射和元组
    scala函数
    scala基础
    Hadoop Eclipse 插件制作以及安装
    理解HBase
    理解HDFS
    Hadoop入门学习路线
    日志框架Log4j
  • 原文地址:https://www.cnblogs.com/yuyu666/p/15190438.html
Copyright © 2011-2022 走看看