I have a small java program that create & delete employee data. I store employee data as .txt (text file). Everything is fine, but it fails to delete the text file.
SIMPLE CLASS TO DELETE text file
public void removeFile(String ID)
{
File file = new File("file"+ID+".txt");
if(file.exists())
{
if(file.delete());
{
System.out.println("\nEmployee has been removed Successfully");
}
}
else
{
System.out.println("\nEmployee does not exists :( ");
}
}
I am getting message "Employee has been removed Successfully" but when I check the root folder, I can still see the file is still there (not deleted).
I tried and checked out different codes online /google, all shows no problem in delete () function.