Am using this code for deleting the specific file in all directories and sub directorates in a drive but its not working. please help me in this regard. If i want to delete the specific file in all drives how to do.
static String refile= "input.txt";
public static void deletemyfile(File directory) {
if (directory.exists()) {
File[] files = directory.listFiles();
if (null != files) {
for (int i = 0; i < files.length; i++) {
System.out.println(files[i].getName());
if (files[i].isDirectory()) {
deletemyfile(files[i]);
} else {
String temp ;
temp = files[i].getName();
if (temp==refile){
System.out.println("name matched and about to delete");
(files[i]).delete();
} else{
System.out.println("name not matched");
}
}
}
}
} else {System.out.println("wrong path");
}
}