File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Need help! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Need help!" Watch "Need help!" New topic
Author

Need help!

Johnson K Jose
Ranch Hand

Joined: Jul 07, 2002
Posts: 36
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

Joined: May 05, 2000
Posts: 13974
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.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Johnson K Jose
Ranch Hand

Joined: Jul 07, 2002
Posts: 36
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

Joined: May 05, 2000
Posts: 13974
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

Joined: Jul 22, 2000
Posts: 9046
    
  10
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 ]

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
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


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Johnson K Jose
Ranch Hand

Joined: Jul 07, 2002
Posts: 36
Dear friends,
Sorry for the delay. Thanks a lot for the information
Regards
Johnson
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help!