This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

try / catch / finally

 
Ernie Mcracken
Ranch Hand
Posts: 33
Mac Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im trying to get my head around try / catch / finally blocks. I want to be able to use finally to close an input stream.. but I can't figure out the code i need to use. Heres what I have. How do I organise my code to get it right?



At compile time I get cannot find symbol: variale fr, I guess this means that I cannot access the fis object from the finally statement, but I don't know how to organise the code so that I can.
 
Matthew Brown
Bartender
Posts: 4549
8
Java Netbeans IDE Scala
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to declare fis outside the block, so it can be accessed in both the try and finally blocks. Like this:
 
Ernie Mcracken
Ranch Hand
Posts: 33
Mac Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That simple! thanks very much.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic