首页 > 其他 > 详细

打印文件夹中的文件

时间:2017-01-25 14:27:25      阅读:197      评论:0      收藏:0      [点我收藏+]

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);

 

}

 

 

}

打印文件夹中的文件

原文:http://www.cnblogs.com/mabel/p/6349370.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!