I have use File delete to delete a file in my local folder however upon executing the line, it doesn't delete right away instead it delete right after I end my application or an error occurs.
After executing the delete line i.e myfile.delete(), the file in my local folder is unable to delete manually as it appear to be used by some other application.
Is there other way that I can delete the file immediately?
String localFilePath = "C:\\Desktop\\smefile.txt";
File file = new File(localFilePath);
if(file.delete()){
System.out.prinln("success");
}
else{
System.out.println("failure");
}