I m facing a problem in production, where sometimes my application was not able to delete the previous processed data files. The following piece of code is used for deletion. It is working properly, once in a file the files are not deleted. so i m not able to figure out the actual cause of the problem. The following code is used. can any one help me on this issue ?

thanks in advance.

public synchronized boolean deleteFiles( String path, String fileExtension ) {
FilterExtension filter = new FilterExtension(fileExtension);
File f = new File(path);
boolean isdeleted = false;
String[] list = f.list(filter);
File f2;
if (list.length == 0)
return true;

for (int i = 0; i < list.length; i++) {
f2 = new File(d + list[i]);
isdeleted = f2.delete();
if (!isdeleted){
throw new IllegalArgumentException("Err");
System.out.println( " deleted ");

return true;