Deleting a file..
I'm simply trying to delete a file using
boolean success = file.delete();
if (!success)
{
System.out.println("Error deleting file.");
}
Sounds simple enough, except -- it isn't returning an accurate value.
It returned false, and when I check the directory, the file had been
deleted.
It does return true, at times, and other times it returns false.
Any ideas?
I need the success boolean to be a valid result...
-Deb
[641 byte] By [
-Deba] at [2007-11-27 8:45:17]

# 1
> Sounds simple enough, except -- it isn't returning an
> accurate value.
>
> It returned false, and when I check the directory,
> the file had been
> deleted.
Assuming that you are right about there being a bug in File.delete (which I find rather doubtful) you can just call File.exists() after deleting to see if the file is still there.
# 2
Thanks for your response.
I tried checking to see if the file exists, but hesitated on knowing if it was
accurate.
This is what I'm doing...
I create a temp folder.
I add two files that are in a temp folder.
I rename the files, (renaming the path, as well) which moves them to a different folder.
I check the contents of the temp folder since I need to delete the contents
in the event of an error occurring when rename fails.
I delete the temp folder.
The method goes smoothly when the files are renamed successfully...
however in order to incorporate the error handling, I need a valid success
value returned.
I've checked the process many times, and file.delete() is not returning correctly when the folder is successfully deleted.
boolean success = file.delete();
.. is returning false and the folder has been deleted.
I am using Java 1.6. Do you know of any issues with it? I checked around
but didn't find anything?
-Deba at 2007-7-12 20:46:22 >
