• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
George Cui
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


when it abort the tmp file is still in the folder.
How to delete the tmp file in case?
thanks
 
Paul Clapham
Sheriff
Pie
Posts: 20171
25
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You just need to declare the variable in a scope which includes both the try-block and the finally-block.
 
George Cui
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, after adding
File tmp_file = null;
at the top, it works
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic