私は(比較的)Javaが初めてで、Windows XPのコマンドプロンプトで次のコマンドのリストを実行する.jarを実装しようとしています。
cd\
cd myfolder
del *.lck /s
私の(失敗した)試み:
// Lists all files in folder
File folder = new File(dir);
File fList[] = folder.listFiles();
// Searchs .lck
for (int i = 0; i < fList.length; i++) {
String pes = fList.get(i);
if (pes.contains(".lck") == true) {
// and deletes
boolean success = (new File(fList.get(i)).delete());
}
}
その「get(i)」のどこかを台無しにしましたが、今では目標にかなり近づいていると思います。
どうぞよろしくお願いいたします。
編集
大丈夫!皆さん、どうもありがとう。提案された3つの変更により、最終的には次のようになりました。
// Lists all files in folder
File folder = new File(dir);
File fList[] = folder.listFiles();
// Searchs .lck
for (int i = 0; i < fList.length; i++) {
String pes = fList[i];
if (pes.endsWith(".lck")) {
// and deletes
boolean success = (new File(fList[i]).delete());
}
}
そして今、それは機能します!