This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman 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


Win a copy of Elasticsearch in Action this week in the Big Data forum!
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
Bartender

Joined: Oct 14, 2005
Posts: 19351
    
  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 agree. Here's the link: http://aspose.com/file-tools
 
subject: How to delete tmp file in the case of abort. Finally block is not in the scope