答:import .*;
public class test implements Runnable{
private File file = null;
public test(File file){
le = file;
}
public void run(){
//此裡面執行對txt檔案的操作
}
public static void main(String[] a){
File f = new File(“你的資料夾路徑“);
//返回該資料夾下所有檔案的名稱列表
String[] name = st();
for(int i=0;i<name.length;i++){
//比較名稱後四位是否是.txt如果是則開啟新的執行緒來處理檔案
if(name[i].substring(name[i].length()-4,name[i].length()-1).equals(“.txt“)){
File fl = new File(name[i]);
test tst = new test(fl);
Thread t = new Thread(tst);
art();
}
}
}
}
答:import .*; public class test implements Runnable{ private File file = null; public test(File file){ le = file; } public void run(){ //此裡面執行對txt檔案的操作 } public static void main(String[] a){ File f = new File(“你的資料夾路徑“); //返回該資料夾下所有檔案的名稱列表 String[] name = st(); for(int i=0;i<name.length;i++){ //比較名稱後四位是否是.txt如果是則開啟新的執行緒來處理檔案 if(name[i].substring(name[i].length()-4,name[i].length()-1).equals(“.txt“)){ File fl = new File(name[i]); test tst = new test(fl); Thread t = new Thread(tst); art(); } } } }