线程类
public class findThread extends Thread {
private String word;
private File fbl;
public findThread(File fbl, String word) throws FileNotFoundException {
this.fbl = fbl;
this.word = word;
}
public void run() {
String s;
FileReader fr = null;
try {
fr = new FileReader(fbl);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
BufferedReader br = new BufferedReader(fr);
try {
while ((s = br.readLine()) != null)
if (s.contains(word)) {
System.out.println(fbl);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
主程序
public class test{
public static void find(String fileDIr,String word) throws IOException {
File f=new File(fileDIr);
File farray[]=f.listFiles();
for(File fbl:farray) {
if(fbl.isFile())