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.
The moose likes Java in General and the fly likes How to delete tmp file in the case of abort. Finally block is not in the scope Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "How to delete tmp file in the case of abort. Finally block is not in the scope" Watch "How to delete tmp file in the case of abort. Finally block is not in the scope" New topic
Author

How to delete tmp file in the case of abort. Finally block is not in the scope

George Cui
Greenhorn

Joined: Dec 10, 2011
Posts: 5


when it abort the tmp file is still in the folder.
How to delete the tmp file in case?
thanks
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19719
    
  10

You just need to declare the variable in a scope which includes both the try-block and the finally-block.
George Cui
Greenhorn

Joined: Dec 10, 2011
Posts: 5
thanks, after adding
File tmp_file = null;
at the top, it works
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: How to delete tmp file in the case of abort. Finally block is not in the scope
 
It's not a secret anymore!