标签:task walk ble this port bsp .exe files current
package searchdir;
import java.io.File;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
public class WalkDirThread {
static ExecutorService pool = Executors.newFixedThreadPool(10);
public static void main(String[] args) {
WalkDirThread wd = new WalkDirThread();
File file = new File("/System");
ThreadTask task = wd.new ThreadTask(file);
Future f = pool.submit(task);
}
class ThreadTask implements Runnable {
private File file;
ThreadTask(File file) {
this.file = file;
}
public void run() {
if (file.isFile()) {
if (file.getName().contains("sys")) {
System.out.println(file.getAbsolutePath());
}
return;
}
if (file.isDirectory()) {
File[] files = file.listFiles();
if (files == null) {
return;
}
for (File o : files) {
pool.submit(new ThreadTask(o));
}
}
}
}
}
标签:task walk ble this port bsp .exe files current
原文地址:http://www.cnblogs.com/mabel/p/6420989.html