I\'m (relatively) new to Java and I\'m trying to implement a .jar that runs a list of commands that in Windows XP\'s command prompt it would be:
cd\\
cd myfolder
fList.get(i)
should be fList[i]
as fList
is an array, and it returns a File
reference not a String
.
Change: -
String pes = fList.get(i);
to: -
File pes = fList[i];
And then change if (pes.contains(".lck") == true)
to
if (pes.getName().contains(".lck"))
In fact, since you are checking for the extension
, you should use endsWith
method rather than contains
method. And yes, you don't need to compare your boolean
value with ==
. So just use this condition: -
if (pes.getName().endsWith(".lck")) {
boolean success = (new File(fList.get(i)).delete());
}