zoukankan      html  css  js  c++  java
  • 打印文件夹中的文件

    package

    intensiveexercise;

     

    import

    java.io.IOException;

    import

    java.nio.file.Files;

    import

    java.nio.file.Path;

    import

    java.nio.file.Paths;

    import

    java.util.concurrent.ExecutorService;

    import

    java.util.concurrent.Executors;

    import

    java.util.concurrent.TimeUnit;

    import

    java.util.stream.Stream;

     

    public

    class Q74 {

     

    public static void main(String[] args) throws IOException, InterruptedException {

    ExecutorService executor=Executors.newCachedThreadPool();

    Stream<Path> listOfFiles=Files.walk(Paths.get("Q:/Users/a496006.DMN1.000/Desktop/file"));

    listOfFiles.forEach(line->{executor.execute(new FileThread(line.getFileName().toString()));});

     

    executor.shutdown();

    executor.awaitTermination(5, TimeUnit.DAYS);

     

    }

     

    }

     

    class

    FileThread implements Runnable{

     

    String fName;

    public FileThread(String fName){

     

    this.fName=fName;

    }

    @Override

    public void run() {

    System.out.println(fName);

     

    }

     

     

    }

  • 相关阅读:
    C语言I博客作业09
    C语言I博客作业08
    C语言I博客作业07
    C语言I博客作业06
    C语言I博客作业05
    C语言II博客作业04
    C语言II博客作业03
    C语言II博客作业02
    C语言|博客作业01
    学期总结
  • 原文地址:https://www.cnblogs.com/mabel/p/6349370.html
Copyright © 2011-2022 走看看