• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help!

 
Johnson K Jose
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Need help!
Why I am getting 'true' for f4.exists() method invocation after calling f4.deleteOnExit()?
This code is working fine.
After running this program, I checked in the Directory for the existence of the files temp3.txt and temp4.txt. Both are not available, I know because I am calling the deleteOnExit() and delete() method.
API says that public void deleteOnExit() Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates.
Is this means still the file pathname can exist? Sorry I am not able to understand this.

 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The API says, "Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates. Deletion will be attempted only for normal termination of the virtual machine, as defined by the Java Language Specification (12.9). "
This means that when the JVM terminates it will do the delete. The JVM terminates when all programs using it have terminated. As you have seen, after your program is finished the delete has been done.
 
Johnson K Jose
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Thomas Paul
Why I am getting 'true' for f4.exists() method invocation after calling f4.deleteOnExit()?
please give me some more info.
Regards
Johnson :roll:
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because the file hasn't been deleted!!! It doesn't get deleted until after every program including yours that is running in this JVM is finsished. If you want to delete it right now then use delete().
 
Marilyn de Queiroz
Sheriff
Posts: 9061
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
f4.deleteOnExit()
This seems like it would delete f4 when you exit, not when you call the method.
[ October 10, 2002: Message edited by: Marilyn de Queiroz ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had this problem sometime ago. Can't remember
where I posted it though. The file did not get deleted after the program had exited. This only
occurred on DOS derivatives (Win-anything).
On Linux/Solaris it worked ok.
-Barry
 
Johnson K Jose
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friends,
Sorry for the delay. Thanks a lot for the information
Regards
Johnson
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic