This week's book giveaway is in the OCAJP forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff 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 OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP 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: 19115
    
    8

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