File[] hiddenFiles = directory.listFiles((FileFilter) HiddenFileFilter.HIDDEN);
for (File hiddenFile : hiddenFiles) {
String hidden = hiddenFile.getCanonicalPath();
File file = new File(hidden);
file.deleteOnExit();
}
I tried this one for deleting a hidden file but this one is not working. Is there any other solution?
There is no difference between deleting a hidden file and a regular file. It should all work well but in your case you are trying to delete file called "hiddenFile". I suggest you remove quotes.
File[] hiddenFiles = directory.listFiles((FileFilter) HiddenFileFilter.HIDDEN);
for (File hiddenFile : hiddenFiles) {
hidenFile.delete();
}
}