This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
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.
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